summaryrefslogtreecommitdiff
path: root/container
diff options
context:
space:
mode:
authorSebastiaan van Stijn <github@gone.nl>2021-08-06 18:50:56 +0200
committerSebastiaan van Stijn <github@gone.nl>2021-08-11 10:31:29 +0200
commite53f65a9168aaf4289a490bd56d9e05b46c08bec (patch)
tree1e784ebb396bdc1aacdc5f86ca3dd8b779ddd965 /container
parent3b316814f9fac27973cb4ce83eb45171105fcbae (diff)
downloaddocker-e53f65a9168aaf4289a490bd56d9e05b46c08bec.tar.gz
pkg/signal: remove DefaultStopSignal const
This const was previously living in pkg/signal, but with that package being moved to its own module, it didn't make much sense to put docker's defaults in a generic module. The const from the "signal" package is currenlty used *both* by the CLI and the daemon as a default value when creating containers. This put up some questions: a. should the default be non-exported, and private to the container package? After all, it's a _default_ (so should be used if _NOT_ set). b. should the client actually setting a default, or instead just omit the value, unless specified by the user? having the client set a default also means that the daemon cannot change the default value because the client (or older clients) will override it. c. consider defaults from the client and defaults of the daemon to be separate things, and create a default const in the CLI. This patch implements option "a" (option "b" will be done separately, as it involves the CLI code). This still leaves "c" open as an option, if the CLI wants to set its own default. Unfortunately, this change means we'll have to drop the alias for the deprecated pkg/signal.DefaultStopSignal const, but a comment was left instead, which can assist consumers of the const to find why it's no longer there (a search showed the Docker CLI as the only consumer though). Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
Diffstat (limited to 'container')
-rw-r--r--container/container.go2
-rw-r--r--container/container_unit_test.go2
-rw-r--r--container/container_unix.go3
-rw-r--r--container/container_windows.go3
4 files changed, 8 insertions, 2 deletions
diff --git a/container/container.go b/container/container.go
index 30317a54c8..a8f267fb59 100644
--- a/container/container.go
+++ b/container/container.go
@@ -518,7 +518,7 @@ func (container *Container) StopSignal() int {
}
if int(stopSignal) == 0 {
- stopSignal, _ = signal.ParseSignal(signal.DefaultStopSignal)
+ stopSignal, _ = signal.ParseSignal(defaultStopSignal)
}
return int(stopSignal)
}
diff --git a/container/container_unit_test.go b/container/container_unit_test.go
index 7c4476c44a..67b36d81b4 100644
--- a/container/container_unit_test.go
+++ b/container/container_unit_test.go
@@ -19,7 +19,7 @@ func TestContainerStopSignal(t *testing.T) {
Config: &container.Config{},
}
- def, err := signal.ParseSignal(signal.DefaultStopSignal)
+ def, err := signal.ParseSignal(defaultStopSignal)
if err != nil {
t.Fatal(err)
}
diff --git a/container/container_unix.go b/container/container_unix.go
index 39ad978761..eef2ee8b3a 100644
--- a/container/container_unix.go
+++ b/container/container_unix.go
@@ -23,6 +23,9 @@ import (
)
const (
+ // defaultStopSignal is the default syscall signal used to stop a container.
+ defaultStopSignal = "SIGTERM"
+
// defaultStopTimeout sets the default time, in seconds, to wait
// for the graceful container stop before forcefully terminating it.
defaultStopTimeout = 10
diff --git a/container/container_windows.go b/container/container_windows.go
index d34edc44a9..8229480df7 100644
--- a/container/container_windows.go
+++ b/container/container_windows.go
@@ -17,6 +17,9 @@ const (
containerInternalSecretMountPath = `C:\ProgramData\Docker\internal\secrets`
containerInternalConfigsDirPath = `C:\ProgramData\Docker\internal\configs`
+ // defaultStopSignal is the default syscall signal used to stop a container.
+ defaultStopSignal = "SIGTERM"
+
// defaultStopTimeout is the timeout (in seconds) for the shutdown call on a container
defaultStopTimeout = 30
)