The shutdown timeout for containers in insufficient on Windows. If the daemon is shutting down, and a container takes longer than expected to shut down, this can cause the container to remain in a bad state after restart, and never be able to start again. Increasing the timeout makes this less likely to occur.
Signed-off-by: Darren Stahl <darst@microsoft.com>
... | ... |
@@ -52,11 +52,6 @@ import ( |
52 | 52 |
|
53 | 53 |
const configFileName = "config.v2.json" |
54 | 54 |
|
55 |
-const ( |
|
56 |
- // DefaultStopTimeout is the timeout (in seconds) for the syscall signal used to stop a container. |
|
57 |
- DefaultStopTimeout = 10 |
|
58 |
-) |
|
59 |
- |
|
60 | 55 |
var ( |
61 | 56 |
errInvalidEndpoint = errors.New("invalid endpoint while building port map info") |
62 | 57 |
errInvalidNetwork = errors.New("invalid network settings while building port map info") |
... | ... |
@@ -16,6 +16,9 @@ const ( |
16 | 16 |
containerSecretMountPath = `C:\ProgramData\Docker\secrets` |
17 | 17 |
containerInternalSecretMountPath = `C:\ProgramData\Docker\internal\secrets` |
18 | 18 |
containerInternalConfigsDirPath = `C:\ProgramData\Docker\internal\configs` |
19 |
+ |
|
20 |
+ // DefaultStopTimeout is the timeout (in seconds) for the shutdown call on a container |
|
21 |
+ DefaultStopTimeout = 30 |
|
19 | 22 |
) |
20 | 23 |
|
21 | 24 |
// UnmountIpcMount unmounts Ipc related mounts. |
... | ... |
@@ -993,7 +993,8 @@ func (daemon *Daemon) Shutdown() error { |
993 | 993 |
} |
994 | 994 |
|
995 | 995 |
if daemon.containers != nil { |
996 |
- logrus.Debugf("start clean shutdown of all containers with a %d seconds timeout...", daemon.configStore.ShutdownTimeout) |
|
996 |
+ logrus.Debugf("daemon configured with a %d seconds minimum shutdown timeout", daemon.configStore.ShutdownTimeout) |
|
997 |
+ logrus.Debugf("start clean shutdown of all containers with a %d seconds timeout...", daemon.ShutdownTimeout()) |
|
997 | 998 |
daemon.containers.ApplyAll(func(c *container.Container) { |
998 | 999 |
if !c.IsRunning() { |
999 | 1000 |
return |
... | ... |
@@ -2789,7 +2789,7 @@ func (s *DockerDaemonSuite) TestDaemonShutdownTimeout(c *check.C) { |
2789 | 2789 |
case <-time.After(5 * time.Second): |
2790 | 2790 |
} |
2791 | 2791 |
|
2792 |
- expectedMessage := `level=debug msg="start clean shutdown of all containers with a 3 seconds timeout..."` |
|
2792 |
+ expectedMessage := `level=debug msg="daemon configured with a 3 seconds minimum shutdown timeout"` |
|
2793 | 2793 |
content, err := s.d.ReadLogFile() |
2794 | 2794 |
c.Assert(err, checker.IsNil) |
2795 | 2795 |
c.Assert(string(content), checker.Contains, expectedMessage) |