-
Notifications
You must be signed in to change notification settings - Fork 98
fix: use retryable http client #5315
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
Conversation
if err != nil { | ||
return "", errors.Wrap(err, "failed to create new request") | ||
} | ||
|
||
reportingInfo := reporting.GetReportingInfo(appID) | ||
reporting.InjectReportingInfoHeaders(req, reportingInfo) | ||
reporting.InjectReportingInfoHeaders(req.Header, reportingInfo) |
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.
does this set the reporting headers correctly on the request because Header
is a map and maps are passed by reference? don't wanna suddenly lose reporting information
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 tested it in a go playground
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 will add a unit test
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.
Added
pkg/util/http.go
Outdated
if bodyStr != "" { | ||
return resp, fmt.Errorf("%s %s giving up after %d attempt(s): %s", | ||
req.Method, redactURL(req.URL), attempt, bodyStr) | ||
} else { |
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.
could get rid of this else
keyword for clarity and return directly
pkg/util/http.go
Outdated
if bodyStr != "" { | ||
return resp, fmt.Errorf("%s %s giving up after %d attempt(s) with error %w: %s", | ||
req.Method, redactURL(req.URL), attempt, err, bodyStr) | ||
} else { |
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.
ditto
pkg/util/http.go
Outdated
header.Add("User-Agent", buildversion.GetUserAgent()) | ||
} | ||
|
||
// errorHandler includes the body in the response when there is an 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.
would this cause OOM if the body was a non-complete binary download? should probably have a cap on the body size that can be read
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.
good call. i made this much more simple
What this PR does / why we need it:
APIs can be flakey. Use retryable http client for resilliency.
https://github.com/replicatedhq/embedded-cluster/actions/runs/14914714913/job/41898012325
Which issue(s) this PR fixes:
Does this PR require a test?
Does this PR require a release note?
Does this PR require documentation?