Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix index scripts #2203

Merged
merged 4 commits into from
Aug 8, 2024
Merged

Fix index scripts #2203

merged 4 commits into from
Aug 8, 2024

Conversation

cmurphy
Copy link
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

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
Copy link

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.

Signed-off-by: Colleen Murphy <colleenmurphy@google.com>
haydentherapper
haydentherapper previously approved these changes Aug 8, 2024
Copy link
Contributor

@haydentherapper haydentherapper 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

set -e
for v in 0.0.1 0.0.2 ; do
rekor-cli --rekor_server $REKOR_ADDRESS upload \
--type intoto:${v} \
Copy link
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
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>
@haydentherapper haydentherapper enabled auto-merge (squash) August 8, 2024 22:07
@haydentherapper haydentherapper merged commit 12c346d into sigstore:main Aug 8, 2024
15 checks passed
@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