Skip to content

Fix index scripts#2203

Merged
Hayden-IO merged 4 commits intosigstore:mainfrom
cmurphy:fix-index-scripts
Aug 8, 2024
Merged

Fix index scripts#2203
Hayden-IO merged 4 commits intosigstore:mainfrom
cmurphy:fix-index-scripts

Conversation

@cmurphy
Copy link
Copy Markdown
Contributor

@cmurphy cmurphy commented Aug 8, 2024

Fix the cleanup-index script for indexes with capitalized keys
(e.g., workload identities for GitHub repositories with capital letters in the name).

Add a new script alongside the backfill script to copy indices directly
from Redis to MySQL. This is created as a separate script from the
backfill script because they are necessary for different purposes:
backfill is appropriate for when there is no data in any search index
backend and the only source of data is the Rekor API, where copy is
apprpriate when there is index data in the Redis database to pull
directly from. This enables the script to copy data that the backfill
script would not be able to recreate because the data needed to generate
the indexes is not always persisted to the Rekor API.

Summary

Release Note

Documentation

cmurphy added 2 commits August 8, 2024 10:24
Some index keys, especially workload identifiers, have uppercase
characters. MySQL is case insensitive, but Redis is not. The index
storage backends account for this by converting lookup keys to lowercase
for Redis queries, but the cleanup script did not account for this and
was leaving some entries present in MySQL undeleted in Redis because
they appeared to be different strings. This change ensures that these
keys will be deleted from Redis when they are fully migrated to MySQL,
even if the case is different.

Signed-off-by: Colleen Murphy <colleenmurphy@google.com>
Remove the copy-pasted make_entries function which is already provided
by the index-test-utils.sh source script.

Signed-off-by: Colleen Murphy <colleenmurphy@google.com>
@cmurphy cmurphy requested a review from a team as a code owner August 8, 2024 18:59
@cmurphy cmurphy requested a review from Hayden-IO August 8, 2024 19:00
@codecov
Copy link
Copy Markdown

codecov Bot commented Aug 8, 2024

Codecov Report

Attention: Patch coverage is 0% with 94 lines in your changes missing coverage. Please review.

Project coverage is 43.02%. Comparing base (488eb97) to head (b486afa).
Report is 173 commits behind head on main.

Files Patch % Lines
cmd/copy-index/main.go 0.00% 92 Missing ⚠️
cmd/cleanup-index/main.go 0.00% 2 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff             @@
##             main    #2203       +/-   ##
===========================================
- Coverage   66.46%   43.02%   -23.44%     
===========================================
  Files          92      189       +97     
  Lines        9258    19462    +10204     
===========================================
+ Hits         6153     8374     +2221     
- Misses       2359    10332     +7973     
- Partials      746      756       +10     
Flag Coverage Δ
e2etests ?
unittests 43.02% <0.00%> (-4.66%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@cmurphy cmurphy force-pushed the fix-index-scripts branch from 13badc4 to ca3c7cb Compare August 8, 2024 19:40
Signed-off-by: Colleen Murphy <colleenmurphy@google.com>
@cmurphy cmurphy force-pushed the fix-index-scripts branch from ca3c7cb to aa86173 Compare August 8, 2024 19:55
Hayden-IO
Hayden-IO previously approved these changes Aug 8, 2024
Copy link
Copy Markdown
Contributor

@Hayden-IO Hayden-IO left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks great! Just one suggested test case to add

Comment thread tests/copy-index-test.sh Outdated
set -e
for v in 0.0.1 0.0.2 ; do
rekor-cli --rekor_server $REKOR_ADDRESS upload \
--type intoto:${v} \
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we also add a test for the dsse type?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

Add a new script alongside the backfill script to copy indices directly
from Redis to MySQL. This is created as a separate script from the
backfill script because they are necessary for different purposes:
backfill is appropriate for when there is no data in any search index
backend and the only source of data is the Rekor API, where copy is
apprpriate when there is index data in the Redis database to pull
directly from. This enables the script to copy data that the backfill
script would not be able to recreate because the data needed to generate
the indexes is not always persisted to the Rekor API.

Signed-off-by: Colleen Murphy <colleenmurphy@google.com>
@Hayden-IO Hayden-IO enabled auto-merge (squash) August 8, 2024 22:07
@Hayden-IO Hayden-IO merged commit 12c346d into sigstore:main Aug 8, 2024
@github-actions github-actions Bot added this to the v1.2.2 milestone Aug 8, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants