-
Notifications
You must be signed in to change notification settings - Fork 4.3k
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 exponential backoff #25497
Added exponential backoff #25497
Conversation
CI Results: |
Build Results: |
This is copied from the ent PR (that I think we can close): I think we should use Also, we can use closing keywords in the description to link the relevant GitHub issues, so that they get updated when this is merged, e.g.: |
@@ -191,6 +199,17 @@ func (ts *Server) Run(ctx context.Context, incoming chan string, templates []*ct | |||
return fmt.Errorf("template server: %w", err) | |||
} | |||
|
|||
// Calculate the amount of time to backoff using exponential backoff | |||
sleep, err := restartBackoff.Next() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Using "next" here in stead of NextSleep so we can log how long it's sleeping for.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks great! Just a small comment remaining.
command/agent/exec/exec.go
Outdated
} | ||
|
||
// Sleep for the calculated backoff time then attempt to create a new runner | ||
ts.logger.Warn(fmt.Sprintf("template server restart: retry attempt after %s", sleep)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm a little confused why this is repeated -- is this a copy/paste error?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ooops yes copy and paste error. Removing now.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks great! Thanks for refactoring to use sdk/backoff
, and good spot fixing it in exec.go
too. I can't really think of a good automated test for this functionality, but as long as you've manually tested, it looks good to go from my perspective!
Awesome work!
Link to ENT PR: https://github.com/hashicorp/vault-enterprise/pull/5444
closes #12566
closes #22789
closes #24657