Fix signal handling for non-leader processes #1680
Merged
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.
Description
This PR fixes a small issue: when Leader Election is enabled, all non-leader processes are waiting on:
https://github.com/GoogleCloudPlatform/spark-on-k8s-operator/blob/c261df66a00635509f7d8cb2a7fba4c602c9228e/main.go#L222
However, this means that they are never getting to this signal-handling logic below:
https://github.com/GoogleCloudPlatform/spark-on-k8s-operator/blob/c261df66a00635509f7d8cb2a7fba4c602c9228e/main.go#L234-L238
This results in non-leader processes not responding to
SIGTERM
orSIGINT
, those signals are simply ignored. The only way to terminate those processes is aSIGKILL
.This PR makes sure that non-leader processes can be terminated with
SIGTERM
orSIGINT
, just like the leader process.Testing
Verified this behaviour in our Kubernetes environment:
kill <PID>
was ignored for non-leader processes but worked for the leader processkill <PID>
successfully terminates both leader and non-leader processes