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

Allow daemonset to handle termination signals #171

Merged

Conversation

martinkennelly
Copy link
Member

Signed-off-by: Martin Kennelly martin.kennelly@intel.com

trap - SIGINT SIGTERM # clear trap
exit 0
}
trap exitonsigterm SIGTERM SIGINT
Copy link
Collaborator

@zshi-redhat zshi-redhat Apr 8, 2021

Choose a reason for hiding this comment

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

I noticed we use exec (https://github.com/k8snetworkplumbingwg/sriov-network-device-plugin/blob/master/images/entrypoint.sh#L70) in sriov device plugin to capture sigterm signal, what is the advantage of using a trap function?

Copy link
Member Author

Choose a reason for hiding this comment

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

@zshi-redhat Do you mean calling exec sleep 1234 so that sleep will be pid 1 and receive SIGTERM? I never thought of that! I tested it and it doesn't work as expected.
I think sleep does not handle sigterm but I cannot confirm from POSIX spec.

So, trap allows us to capture a SIGTERM and force exit. If sleep handled a SIGTERM, exec would be fine. I pushed a commit to simplify what I had previously. There was no need to clear the trap.
Without this patch deleting the pod takes 1m30s.
With this patch delete the pod takes 30s.

Copy link
Collaborator

Choose a reason for hiding this comment

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

@zshi-redhat Do you mean calling exec sleep 1234 so that sleep will be pid 1 and receive SIGTERM?
Yes
I never thought of that! I tested it and it doesn't work as expected.
Thanks for testing it!
I think sleep does not handle sigterm but I cannot confirm from POSIX spec.

So, trap allows us to capture a SIGTERM and force exit. If sleep handled a SIGTERM, exec would be fine. I pushed a commit to simplify what I had previously. There was no need to clear the trap.
Without this patch deleting the pod takes 1m30s.
With this patch delete the pod takes 30s.

Big improvement!
Thanks for the fix!

Signed-off-by: Martin Kennelly <martin.kennelly@intel.com>
@martinkennelly martinkennelly merged commit 7ee9313 into k8snetworkplumbingwg:master Apr 12, 2021
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