Skip to content
This repository has been archived by the owner on Feb 8, 2021. It is now read-only.

Enable force kill container with SIGKILL if timeout #559

Merged
merged 3 commits into from
Mar 27, 2017

Conversation

Crazykev
Copy link
Contributor

ref: #549

  • I use FutureSet workflow to re-implement stopContainers() to enable force kill container after timeout, change the way it works, original graceful guarantee stopContianers() will return in graceful time, now ensure container have graceful time to stop with default signal before forcibly kill it.
  • remove cMap and eMap, since we don't need it in current approach(Am I correct?)
  • Also add timeout in StopContainer grpc api since CRI need it(/cc @feiskyer )

enable force kill after graceful time

Signed-off-by: Crazykev <crazykev@zju.edu.cn>
Signed-off-by: HaoZhang <crazykev@zju.edu.cn>
Signed-off-by: HaoZhang <crazykev@zju.edu.cn>

future := utils.NewFutureSet()
waitTime := time.Duration(graceful) * time.Second
if graceful == 0 {
Copy link
Member

Choose a reason for hiding this comment

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

IMHO, if graceful == 0, we should not wait, and fire force kill directly.

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, if graceful == 0, it is force kill directly:

...
forceKill := graceful == 0
resChan := p.sandbox.WaitProcess(true, []string{c.Id()}, -1)
err := c.terminate(forceKill)
...

This waitTime is the time we wait for container finish event before abort this mission(or try it with SIGKILL in non-zero graceful)

Copy link
Member

Choose a reason for hiding this comment

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

Then, do we need wait 5 seconds and kill again?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

If graceful == 0, it just wait 5s and won't kill again(return timeout error); if kill with image specified signal(graceful != 0), it will wait graceful time to kill with SIGKILL again.
Is this 5 seconds too long?

Copy link
Member

Choose a reason for hiding this comment

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

If graceful == 0, does this mean the user don't want to wait anything, just return at once?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Nop if we use docker:

$ docker stop --help

Usage:	docker stop [OPTIONS] CONTAINER [CONTAINER...]

Stop a running container.
Sending SIGTERM and then SIGKILL after a grace period

  --help             Print usage
  -t, --time=10      Seconds to wait for stop before killing it

or k8s way:
https://github.com/kubernetes/kubernetes/blob/master/pkg/kubelet/api/v1alpha1/runtime/api.proto#L653-L658

@gnawux gnawux added this to the v0.8.1 milestone Mar 21, 2017
@gnawux
Copy link
Member

gnawux commented Mar 21, 2017

@laijs could you review this patch? Its size is far beyond what I imagined before, but looks good except for the grace==0 case.

@laijs
Copy link
Contributor

laijs commented Mar 26, 2017

LGTM

@gao-feng gao-feng merged commit a42feae into hyperhq:master Mar 27, 2017
@Crazykev Crazykev deleted the force-kill branch March 27, 2017 02:01
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants