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

handle runc command context manually #28

Closed
wants to merge 1 commit into from

Conversation

dqminh
Copy link
Member

@dqminh dqminh commented Sep 21, 2017

instead of defering to Go's stdlib to handle context, which only sends
SIGKILL when the context timed out, handle the context timeout ourselves
so we can inject a custom signal first ( default to SIGTERM, and send
SIGKILL after 10 seconds) to stop container more gracefully.

Fix #21
Replace #22

instead of defering to Go's stdlib to handle context, which only sends
SIGKILL when the context timed out, handle the context timeout ourselves
so we can inject a custom signal first ( default to SIGTERM, and send
SIGKILL after 10 seconds) to stop container more gracefully.

If no signal is specified, then fall back to sending SIGKILL just like
stdlib.

Fix containerd#21
@crosbymichael
Copy link
Member

How are we supposed to implement this in the reaper for containerd? Is this really worth fixing?

If so, it maybe better to just update go's exec package to allow you to set a os.Signal on the context in the exec package that is used.

@dqminh
Copy link
Member Author

dqminh commented Sep 22, 2017

@crosbymichael yah the reaper in containerd will need to be changed to handle context itself similar to how the current default reaper is changed. We have to handle signaling in Start / finish in Wait.

I'm also trying to get this in stdlib, but so far there hasnt been any aggreements on the api yet golang/go#21135

@crosbymichael
Copy link
Member

I replied about a simple API change to enable it.

@dqminh
Copy link
Member Author

dqminh commented Sep 28, 2017

@crosbymichael since we cant settle on the upstream design, should we do this ?

@crosbymichael
Copy link
Member

How do you feel about it? Is it worth the extra complexity in our code and the extra go routine?

@dqminh
Copy link
Member Author

dqminh commented Sep 28, 2017

@crosbymichael i think it makes sense to terminate gracefully. The goroutine is already there if you use CommandContext ( it creates one internally at the end of Start to watch for context timeout and sigkill ).

c.Process.Signal(unix.SIGKILL)
} else {
c.Process.Signal(m.defaultSignal)
if m.killTimeout > 0 {
Copy link
Collaborator

Choose a reason for hiding this comment

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

If there's no killtimeout set better use a default value, the process may never die otherwise.

@crosbymichael
Copy link
Member

Do we have an idea how we will implement this in the reaper because its a little different than blocking in a go routine here.

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.

Kill exec process with SIGTERM instead of SIGKILL
4 participants