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

Add concurrency to backfill-redis #1504

Merged
merged 2 commits into from
May 25, 2023

Conversation

codysoyland
Copy link
Member

@codysoyland codysoyland commented May 24, 2023

This adds concurrency to the backfill-redis command, including:

  • Configurable -concurrency flag to set worker pool size, defaulting to 1
  • -dry-run flag to test without writing to Redis
  • Signal handler to exit on SIGTERM

Fixes #1501

@codysoyland codysoyland requested a review from a team as a code owner May 24, 2023 19:00
Signed-off-by: Cody Soyland <codysoyland@github.com>
@codysoyland
Copy link
Member Author

/cc @haydentherapper

@codecov
Copy link

codecov bot commented May 24, 2023

Codecov Report

Merging #1504 (406d603) into main (35c4489) will not change coverage.
The diff coverage is n/a.

@@           Coverage Diff           @@
##             main    #1504   +/-   ##
=======================================
  Coverage   67.01%   67.01%           
=======================================
  Files          82       82           
  Lines        8325     8325           
=======================================
  Hits         5579     5579           
  Misses       2077     2077           
  Partials      669      669           
Flag Coverage Δ
e2etests 48.90% <ø> (-0.03%) ⬇️
unittests 47.50% <ø> (ø)

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

if err != nil {
insertErrs = append(insertErrs, fmt.Errorf("error building index keys for %s: %v", uuid, err))
continue
log.Fatalf("retrieving log uuid by index: %v", err)
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 change this to just print the error?

Copy link
Member Author

Choose a reason for hiding this comment

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

We can, but I want to highlight that this is the current behavior (I wish the GitHub diff showed character-level diff so we can see that this whole block was indented and barely modified), and when I ran this on production (over ~50,000 entries), I never hit this. So IMO, I would rather retain this behavior -- bail if the Rekor call fails, since that likely indicates a config/networking problem. Let me know, I'm happy to change it if you disagree.

Copy link
Contributor

Choose a reason for hiding this comment

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

Fair point, I'm ok with keeping this as is.

}
return nil
})
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Could we also track which indices couldn't be backfilled and log those?

Copy link
Member Author

Choose a reason for hiding this comment

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

Not sure if this is what you had in mind, but I added a result summary in my last commit. It does make a simple script a bit more complex, so I'm totally fine removing/changing it.

I decided to separate "parse errors" from "insert errors" when collating results, as I think parse errors are sort of unactionable and insert errors might be recoverable.

The results appear at the end of the command output, for example:

...
Uploaded Redis entry 24296fb24b8ad77abe5d0de220d5e64d0b52178d175a5833a5e327928368a2c9beea87009046c16d, index 21320998, key sha256:ee2ae5b13687d4d443a206359ad7c24a31b753c2233d9d1cb04dbe88535d09db
Completed log index 21320998
Backfill complete
Failed to parse 2 entries: [21320576 21320640]
Failed to insert/remove 1 entries: [21320316]

Copy link
Contributor

Choose a reason for hiding this comment

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

This looks great!!

Signed-off-by: Cody Soyland <codysoyland@github.com>
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.

Thanks for cleaning this up!

@bobcallaway bobcallaway merged commit 3adca0d into sigstore:main May 25, 2023
14 checks passed
@github-actions github-actions bot added this to the v1.1.0 milestone May 25, 2023
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.

Add concurrency to backfill-redis script
3 participants