mirror of
https://github.com/moby/moby.git
synced 2025-08-01 05:47:11 +03:00
Add --stop-signal
for service create
and service update
This fix tries to address the issue raised in 25696 where it was not possible to specify `--stop-signal` for `docker service create` and `docker service update`, in order to use special signal to stop the container. This fix adds `--stop-signal` and update the `StopSignal` in `Config` through `service create` and `service update`. Related docs has been updated. Integration test has been added. This fix fixes 25696. Signed-off-by: Yong Tang <yong.tang.github@outlook.com>
This commit is contained in:
@ -1764,3 +1764,31 @@ func (s *DockerSwarmSuite) TestNetworkInspectWithDuplicateNames(c *check.C) {
|
||||
c.Assert(err, checker.NotNil, check.Commentf(out))
|
||||
c.Assert(out, checker.Contains, "network foo is ambiguous (2 matches found based on name)")
|
||||
}
|
||||
|
||||
func (s *DockerSwarmSuite) TestSwarmStopSignal(c *check.C) {
|
||||
testRequires(c, DaemonIsLinux, UserNamespaceROMount)
|
||||
|
||||
d := s.AddDaemon(c, true, true)
|
||||
|
||||
out, err := d.Cmd("service", "create", "--name", "top", "--stop-signal=SIGHUP", "busybox", "top")
|
||||
c.Assert(err, checker.IsNil, check.Commentf(out))
|
||||
|
||||
// make sure task has been deployed.
|
||||
waitAndAssert(c, defaultReconciliationTimeout, d.CheckActiveContainerCount, checker.Equals, 1)
|
||||
|
||||
out, err = d.Cmd("service", "inspect", "--format", "{{ .Spec.TaskTemplate.ContainerSpec.StopSignal }}", "top")
|
||||
c.Assert(err, checker.IsNil, check.Commentf(out))
|
||||
c.Assert(strings.TrimSpace(out), checker.Equals, "SIGHUP")
|
||||
|
||||
containers := d.ActiveContainers()
|
||||
out, err = d.Cmd("inspect", "--type", "container", "--format", "{{.Config.StopSignal}}", containers[0])
|
||||
c.Assert(err, checker.IsNil, check.Commentf(out))
|
||||
c.Assert(strings.TrimSpace(out), checker.Equals, "SIGHUP")
|
||||
|
||||
out, err = d.Cmd("service", "update", "--stop-signal=SIGUSR1", "top")
|
||||
c.Assert(err, checker.IsNil, check.Commentf(out))
|
||||
|
||||
out, err = d.Cmd("service", "inspect", "--format", "{{ .Spec.TaskTemplate.ContainerSpec.StopSignal }}", "top")
|
||||
c.Assert(err, checker.IsNil, check.Commentf(out))
|
||||
c.Assert(strings.TrimSpace(out), checker.Equals, "SIGUSR1")
|
||||
}
|
||||
|
Reference in New Issue
Block a user