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鈥檒l occasionally send you account related emails.
Already on GitHub? Sign in to your account
WIP: fix graceful shutdown, add SIGTERM handler #1951
Draft
frostmar
wants to merge
1
commit into
quay:main
Choose a base branch
from
frostmar:graceful-shutdown
base: main
Could not load branches
Branch not found: {{ refName }}
Could not load tags
Nothing to show
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Adds signal handling for SIGTERM Allows graceful shutdown to complete (instead of HTTP requests in-flight being terminated) WIP: doesn't allow time for in-flight requests to finish. The context is cancelled for each in-flight request as a side-effect of the way servers shutdown and a parent context is cancelled Signed-off-by: Mark Frost <frostmar@uk.ibm.com>
Can one of the admins verify this patch? |
Example running this code
Clair logs:
|
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
An attempt to address issue #1946
馃憤 Adds signal handling for SIGTERM
馃憤 Allows graceful shutdown to complete (instead of HTTP requests in-flight being terminated suddenly)
馃憥 doesn't allow time for in-flight requests to finish. The context is cancelled for each in-flight request as a side-effect of the way servers shutdown and a parent context is cancelled. I can't see a way to get this to work as I'd like, so opening this draft PR for suggestions or discussion.
I believe the code flow is now:
down.Shutdown(tctx)
, causing each server to stop listening for new requests, and immediately returnhttp.ErrServerClosed
from theirServe()
orListenAndServe()
callssrvs.Wait()
immediately completes for the server ErrorGroup, cancelling it's contextsrvctx
srvctx
is a parent of each http request's context, so each in-flight request begins context-cancellation processingI tried not having all request contexts children of
srvctx
, but got lots of context-related warnings logged frompkg/ctxlock/ctxlock.go
during graceful shutdownIn practice this changes the behaviour seen when clair does a graceful shutdown -
From:
To: