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

Clean shutdown #92

Merged
merged 2 commits into from
Dec 19, 2024
Merged

Clean shutdown #92

merged 2 commits into from
Dec 19, 2024

Conversation

eparker-tulip
Copy link
Contributor

@eparker-tulip eparker-tulip commented Dec 16, 2024

Oplogtoredis already captured the SIGINT signal, but this adds SIGTERM as well, which is what k8s sends for termination of a pod. This allows for graceful and clean shutdown. Also corrects a panic from the HTTP server exit that was interrupting the clean shutdown process. Tested locally and confirmed shutdown is working as expected.

Copy link
Contributor

@alex-goodisman alex-goodisman left a comment

Choose a reason for hiding this comment

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

LGTM

// Start one more goroutine for the HTTP server
httpServer := makeHTTPServer(aggregatedRedisClients, aggregatedMongoSessions, denylist, syncer)
go func() {
httpErr := httpServer.ListenAndServe()
if httpErr != nil {
if shuttingDown {
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 race condition?

Copy link
Contributor

Choose a reason for hiding this comment

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

small deal since the only result is the wrong log message but worth making sure the handlers go off in the right order.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, but like you mentioned I'm not sure it matters. The risk is that if it's shut down in the middle of an HTTP server error it won't get reported. The handlers seem to work correctly from my testing. We have three options here: 1) leave as-is, 2) include the HTTP error (messier), 3) add locks (more complexity).

@eparker-tulip eparker-tulip merged commit 1a903e3 into master Dec 19, 2024
8 checks passed
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.

2 participants