-
Notifications
You must be signed in to change notification settings - Fork 82
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
Use Shutdown to gracefully halt HTTP servers #3165
Conversation
Use the Shutdown method with a timeout to try to gracefully shutdown HTTP connections. If the server times out while attempting to drain the connections, connections are forced closed. If there is a long-polling checkin request, the server should send a 200 response with the ack token used in the request (same behaviour as the poll completing normally).
2839a6c
to
78adfdb
Compare
Does anyone know why the linter is all of a sudden having issues with our apm imports? |
@michel-laterman Looks like the linter is ok and only Sonar analysis complains about the insufficient code coverage. |
The changes to handleCheckin should be covered by the new integration test (but coverage for those tests don't work as expected). I've also added a test case for the profiler |
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.
Code-wise LGTM, not tested.
resp, err = http.DefaultClient.Do(req) //nolint:bodyclose // closed outside the loop | ||
if err == nil { |
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.
Nit. Could it be closed here?
resp, err = http.DefaultClient.Do(req) //nolint:bodyclose // closed outside the loop | |
if err == nil { | |
resp, err = http.DefaultClient.Do(req) | |
if err == nil { | |
resp.Body.Close() |
buildkite test it |
@nchaulet @michel-laterman all tests passed, shall we merge this? |
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.
Tested locally and it seems to work as expected 🚀
Quality Gate passedThe SonarQube Quality Gate passed, but some issues were introduced. 1 New issue |
What is the problem this PR solves?
Checkin API long-poll connections terminate with an error when the server needs to shut down (providing a 5xx to the client).
How does this PR solve the problem?
Use the Shutdown method with a timeout to try to gracefully shutdown
HTTP connections. If the server times out while attempting to drain the
connections, connections are forced closed. If there is a long-polling
checkin request, the server should send a 200 response with the ack
token used in the request (same behaviour as the poll completing
normally).
Design Checklist
I have included fail safe mechanisms to limit the load on fleet-server: rate limiting, circuit breakers, caching, load shedding, etc.Checklist
./changelog/fragments
using the changelog toolRelated issues