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

Taking stop-signal into account when docker kill #26464

Merged

Conversation

vdemeester
Copy link
Member

@vdemeester vdemeester commented Sep 10, 2016

- What I did

This fix tries to address the issue #11065, taking into account stop-signal if present so that non-fatal signal (i.e. SIGKILL) is sent using docker kill command, it will not disable the restart policy. 🐯

- How to verify it

Added 2 integration tests to handle those cases.

- Still todo

  • Validate SIGKILL behavior
  • Update documentation

This fix fixes #11065.

/cc @tonistiigi @crosbymichael

🐸

Signed-off-by: Vincent Demeester vincent@sbr.pm

@vdemeester
Copy link
Member Author

/cc @mlaventure @thaJeztah @cpuguy83 👼

@@ -47,7 +47,7 @@ func (s *DockerSuite) TestKillDifferentUserContainer(c *check.C) {

// regression test about correct signal parsing see #13665
func (s *DockerSuite) TestKillWithSignal(c *check.C) {
// Cannot port to Windows - does not support signals in the same was a Linux does
// Cannot port to Windows - does not support signals in the same way a Linux does
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: "same way a Linux does"

Copy link
Member Author

Choose a reason for hiding this comment

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

😅

@@ -105,6 +115,9 @@ func (daemon *Daemon) Kill(container *container.Container) error {
return errNotRunning{container.ID}
}

// FIXME(vdemeester) should we disable restartpolicy for SIGKILL or not ?
Copy link
Contributor

Choose a reason for hiding this comment

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

From my POV I would expect the RestartPolicy to only be disabled if the kill was generated as part of a docker stop command.

WDYT?

Copy link
Member Author

Choose a reason for hiding this comment

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

@mlaventure you mean the SIGKILL sent after the grace period right ?

I'm not really sure in fact. Naively, I would consider SIGKILL as the fatal signal, and thus, the only signal that always disable restart policy.

Copy link
Contributor

Choose a reason for hiding this comment

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

But the SIGKILL could have been sent as part of the oom policy in which case, I'd probably want my container restarted since the targeted process are more or less random

Copy link
Member Author

Choose a reason for hiding this comment

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

@mlaventure hum… true, so SIGKILL would be treated exactly as the other signals then. docker stop sends the stop-signal if present, and thus, the restart manager would disable the restart policy, even if the SIGKILL is sent afterwards.

@crosbymichael @LK4D4 @cpuguy83 @thaJeztah WDYT ? I can update to reflect that.

Copy link
Member

Choose a reason for hiding this comment

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

I need to read up on this issue again 😄, and see what's the most logical behavior here

Copy link
Member

Choose a reason for hiding this comment

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

So, this is only in the case of a shutdown, correct? I think a shutdown should not influence the restart policy, independent of the signal that was used (i.e. if the container was running, and it's killed as part of the shutdown, the intent was to have it running, so --restart=unless-stopped still applies).

Copy link
Member

Choose a reason for hiding this comment

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

Ok after some discussion; it's better to keep the current behavior here; can your remove this?

Copy link
Member Author

Choose a reason for hiding this comment

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

I can 😝

@@ -105,6 +115,9 @@ func (daemon *Daemon) Kill(container *container.Container) error {
return errNotRunning{container.ID}
}

// FIXME(vdemeester) should we disable restartpolicy for SIGKILL or not ?
Copy link
Member

Choose a reason for hiding this comment

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

Ok after some discussion; it's better to keep the current behavior here; can your remove this?

If a container sets a stop-signal, taking it into account to disable or
not the restart policy.

Signed-off-by: Vincent Demeester <vincent@sbr.pm>
@vdemeester vdemeester force-pushed the 11065-stop-signal-and-restart-policies branch from e7184cc to d2e6424 Compare October 24, 2016 18:10
@vdemeester
Copy link
Member Author

PR updated, withouth changes on kill 😛

container.ExitOnNext()
}
} else {
container.ExitOnNext()
Copy link
Contributor

Choose a reason for hiding this comment

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

Just realized, shouldn't we check that the signal being sent is the stop signal here too before disabling the restartmanager?

Copy link
Member Author

Choose a reason for hiding this comment

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

If the container has no StopSignal then doing the same as before (for retro-compatibility sake 😅) 👼

Copy link
Contributor

Choose a reason for hiding this comment

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

Yes, I noticed it was the same before. It just feels weird. This can be done in a subsequent PR anyhow I guess.

cc @tonistiigi

@thaJeztah thaJeztah added this to the 1.13.0 milestone Oct 27, 2016
@crosbymichael
Copy link
Contributor

LGTM

@crosbymichael crosbymichael merged commit 9e436c9 into moby:master Oct 28, 2016
@vdemeester vdemeester deleted the 11065-stop-signal-and-restart-policies branch October 28, 2016 18:14
liusdu pushed a commit to liusdu/moby that referenced this pull request Oct 30, 2017
If a container sets a stop-signal, taking it into account to disable or
not the restart policy.

fix DTS2017062802264

backport from moby#26464 without conflicts.

Signed-off-by: Vincent Demeester <vincent@sbr.pm>
Signed-off-by: Yuanhong Peng <pengyuanhong@huawei.com>
liusdu pushed a commit to liusdu/moby that referenced this pull request Oct 30, 2017
Taking stop-signal into account when docker kill

If a container sets a stop-signal, taking it into account to disable or
not the restart policy.

fix DTS2017062802264

backport from moby#26464 without conflicts.

Signed-off-by: Vincent Demeester <vincent@sbr.pm>
Signed-off-by: Yuanhong Peng <pengyuanhong@huawei.com>



See merge request docker/docker!604
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Non-fatal signals break restart policies
5 participants