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

Added backoff and retry logic #578

Merged
merged 5 commits into from
Feb 3, 2025
Merged

Conversation

Horiodino
Copy link
Contributor

Summary

This PR adds retry logic for handling errors that are considered retryable types. The system will now automatically retry failed operations for a specified time duration and number of iterations

Fixes : #322 (comment)

Release Note

Documentation

Signed-off-by: Horiodino <holiodin@gmail.com>
Signed-off-by: Horiodino <holiodin@gmail.com>
Copy link

codecov bot commented Jan 15, 2025

Codecov Report

Attention: Patch coverage is 58.33333% with 50 lines in your changes missing coverage. Please review.

Project coverage is 57.14%. Comparing base (d271ec7) to head (f6e651f).
Report is 215 commits behind head on main.

Files with missing lines Patch % Lines
pkg/util/retry.go 53.27% 41 Missing and 9 partials ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #578      +/-   ##
==========================================
- Coverage   64.02%   57.14%   -6.89%     
==========================================
  Files           4       19      +15     
  Lines         303     1617    +1314     
==========================================
+ Hits          194      924     +730     
- Misses         78      600     +522     
- Partials       31       93      +62     

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

@Horiodino
Copy link
Contributor Author

Horiodino commented Jan 15, 2025

Hey @haydentherapper , I wasn’t able to view the reference you provided because the action logs have expired. Please make sure to test the changes and let me know the results. already added test case

@@ -283,10 +284,19 @@ func GetCheckpointIndex(logInfo *models.LogInfo, checkpoint *util.SignedCheckpoi
}

func IdentitySearch(startIndex int, endIndex int, rekorClient *client.Rekor, monitoredValues identity.MonitoredValues, outputIdentitiesFile string, idMetadataFile *string) ([]identity.MonitoredIdentity, error) {
entries, err := GetEntriesByIndexRange(context.Background(), rekorClient, startIndex, endIndex)
resp, err := util.Retry(context.Background(), func() (interface{}, error) {
entries, err := GetEntriesByIndexRange(context.Background(), rekorClient, startIndex, endIndex)
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 wrap each of the outbound calls in

func GetEntriesByIndexRange(ctx context.Context, rekorClient *client.Rekor, start, end int) ([]models.LogEntry, error) {
rather than here? Otherwise, we'll retry a potentially large range of requests.

pkg/util/retry.go Outdated Show resolved Hide resolved
pkg/util/retry.go Outdated Show resolved Hide resolved
Signed-off-by: Horiodino <holiodin@gmail.com>
Signed-off-by: Horiodino <holiodin@gmail.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 so much, this looks great! Just a few tiny comments.

@@ -73,11 +74,13 @@ func GetEntriesByIndexRange(ctx context.Context, rekorClient *client.Rekor, star
p := entries.NewSearchLogQueryParamsWithContext(ctx)
p.SetEntry(&slq)

resp, err := rekorClient.Entries.SearchLogQuery(p)
resp, err := util.Retry(ctx, func() (any, error) {
return rekorClient.Entries.SearchLogQuery(p)
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 wrap the other two usages of rekorClient in the above functions?

@@ -32,7 +32,7 @@ import (
"github.com/sigstore/rekor/pkg/generated/models"
"github.com/sigstore/rekor/pkg/pki"
"github.com/sigstore/rekor/pkg/types"
"github.com/sigstore/rekor/pkg/util"
rekorutils "github.com/sigstore/rekor/pkg/util"
Copy link
Contributor

Choose a reason for hiding this comment

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

Undo?

@@ -0,0 +1,170 @@
// Copyright 2022 The Sigstore Authors.
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
// Copyright 2022 The Sigstore Authors.
// Copyright 2025 The Sigstore Authors.

@@ -0,0 +1,190 @@
// Copyright 2022 The Sigstore Authors.
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
// Copyright 2022 The Sigstore Authors.
// Copyright 2025 The Sigstore Authors.

Signed-off-by: Horiodino <holiodin@gmail.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.

thank you!

@haydentherapper haydentherapper merged commit f00360b into sigstore:main Feb 3, 2025
8 checks passed
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.

Handle Rekor shutdown properly
2 participants