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

Check for termination file before starting #44

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

patrickmariglia
Copy link

@patrickmariglia patrickmariglia commented Aug 22, 2023

A workaround to be sure, but I've written worse code.

This adds a file /tmp/sparkplug_ready after sparkplug has registered
its signal handlers. This gives workloads running in kubernetes the
ability to check for this file before sending a signal to terminate.

While #42 did add a signal
handler to make sure sparkplug exits after processing a message,
there are extremely rare situations where kubernetes sends a TERM
signal before sparkplug registers it's signal handler. In these situations,
the TERM is swallowed up and eventually a KILL is executed at an
arbitrary time, causing issues.

@mmazer
Copy link

mmazer commented Aug 22, 2023

Based on the edge case that we seem to have discovered, this should do the job and is simple.

@jappievw
Copy link

Thanks @patrickmariglia! This could work for sure. I was thinking the other way around: writing a pid-file after the signal handlers are registered and have the pre stop hook wait for the pid-file to exist. I don't have a preference when we know it works.

A workaround to be sure, but I've written worse code.

This adds a file `/tmp/sparkplug_ready` after sparkplug has registered
its signal handlers. This gives workloads running in kubernetes the
ability to check for this file before sending a signal to terminate.

While #42 did add a signal handler to make sure sparkplug exits _after_ processing a message, there are extremely rare situations where kubernetes sends a TERM signal before sparkplug registers it's signal handler. In these situations, the TERM is swallowed up and eventually a KILL is executed at an arbitrary time, causing issues.
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.

3 participants