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

Switch to avast/retry-go for HTTP retry #2350

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

saschagrunert
Copy link
Contributor

Summary

The hashicorp dependencies are MPL licensed and therefore not allowed in the CNCF. This means we now use the avast/retry-go implementation to achieve the same goal.

Release Note

Use github.com/avast/retry-go instead of github.com/hashicorp/go-retryablehttp for HTTP request retry.

Documentation

None

Fixes #2342

@saschagrunert saschagrunert requested a review from a team as a code owner January 29, 2025 10:25
Copy link

codecov bot commented Jan 29, 2025

Codecov Report

Attention: Patch coverage is 65.45455% with 19 lines in your changes missing coverage. Please review.

Project coverage is 49.86%. Comparing base (488eb97) to head (3f3e3b0).
Report is 300 commits behind head on main.

Files with missing lines Patch % Lines
pkg/client/options.go 48.64% 16 Missing and 3 partials ⚠️
Additional details and impacted files
@@             Coverage Diff             @@
##             main    #2350       +/-   ##
===========================================
- Coverage   66.46%   49.86%   -16.61%     
===========================================
  Files          92      192      +100     
  Lines        9258    24773    +15515     
===========================================
+ Hits         6153    12352     +6199     
- Misses       2359    11318     +8959     
- Partials      746     1103      +357     
Flag Coverage Δ
e2etests 46.51% <58.18%> (-1.05%) ⬇️
unittests 41.90% <65.45%> (-5.79%) ⬇️

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.

@saschagrunert saschagrunert force-pushed the retry-go branch 6 times, most recently from 9ae3e8f to 003ab22 Compare January 30, 2025 09:05
@saschagrunert
Copy link
Contributor Author

Green CI :)

cpanato
cpanato previously approved these changes Jan 30, 2025
pkg/client/options.go Outdated Show resolved Hide resolved
pkg/client/options.go Outdated Show resolved Hide resolved
func createRoundTripper(inner http.RoundTripper, o *options) http.RoundTripper {
var tooManyRedirectyRe = regexp.MustCompile(`stopped after \d+ redirects\z`)

func shouldRetry(resp *http.Response, err error) error {
Copy link
Contributor

Choose a reason for hiding this comment

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

Is this a change in behavior or is this copied from go-retryable's implementation?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It's not copied over, but it should reflect the same retry behavior.

ForceAttemptHTTP2: true,
MaxIdleConnsPerHost: -1,
DisableKeepAlives: !o.NoDisableKeepalives,
TLSClientConfig: &tls.Config{InsecureSkipVerify: o.InsecureTLS}, //nolint:gosec
Copy link
Contributor

Choose a reason for hiding this comment

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

Previously this was only set if o.InsecureTLS. Should we maintain that, or is there no change in behavior? I'm not sure if there's a default tls config we're overriding.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Changed it to only apply if o.InsecureTLS, but I assume it's the same as before in the end.

The hashicorp dependencies are MPL licensed and therefore not allowed in
the CNCF. This means we now use the `avast/retry-go` implementation to
achieve the same goal.

Signed-off-by: Sascha Grunert <[email protected]>
@@ -132,7 +131,9 @@ require (
github.com/google/pprof v0.0.0-20240727154555-813a5fbdbec8 // indirect
github.com/google/s2a-go v0.1.9 // indirect
github.com/hashicorp/errwrap v1.1.0 // indirect
github.com/hashicorp/go-cleanhttp v0.5.2 // indirect
Copy link
Member

Choose a reason for hiding this comment

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

looks like these are still indirects (probably because of us supporting hashivault)... is that still an issue for CNCF?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think so, but the code does not seem to be imported from kubernetes-sigs/release-sdk, we may follow-up on that, though.

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.

MPL-licensed github.com/hashicorp/go-retryablehttp is not allowed in CNCF
4 participants