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 exponential backoff #25497

Merged
merged 8 commits into from
Feb 20, 2024
Merged

Conversation

divyaac
Copy link
Contributor

@divyaac divyaac commented Feb 16, 2024

@github-actions github-actions bot added the hashicorp-contributed-pr If the PR is HashiCorp (i.e. not-community) contributed label Feb 16, 2024
Copy link

github-actions bot commented Feb 16, 2024

CI Results:
All Go tests succeeded! ✅

Copy link

github-actions bot commented Feb 16, 2024

Build Results:
All builds succeeded! ✅

@VioletHynes
Copy link
Contributor

VioletHynes commented Feb 20, 2024

This is copied from the ent PR (that I think we can close):

I think we should use sdk/backoff.go for this, as this is the same backoff mechanism we use for auto-auth. It's familiar to customers in the way that it works, and that means we don't have multiple different 'kinds' of backoffs within Agent. We can use nice helpers like NextSleep that way, too!

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.:

closes #12566
closes #22789
closes #24657

@@ -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()
Copy link
Contributor Author

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.

Copy link
Contributor

@VioletHynes VioletHynes 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 a small comment remaining.

}

// 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))
Copy link
Contributor

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?

Copy link
Contributor Author

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.

Copy link
Contributor

@VioletHynes VioletHynes 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! 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!

@divyaac divyaac merged commit 3132592 into main Feb 20, 2024
83 checks passed
@divyaac divyaac deleted the VAULT-23841_Agent_Retry_Backoff_Templating branch February 20, 2024 19:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
hashicorp-contributed-pr If the PR is HashiCorp (i.e. not-community) contributed pr/no-milestone
Projects
None yet
2 participants