Browse Source

Merge pull request #42717 from thaJeztah/move_defaults

Brian Goff 3 years ago
parent
commit
a44a8e54ce

+ 2 - 2
container/container.go

@@ -518,7 +518,7 @@ func (container *Container) StopSignal() int {
 	}
 	}
 
 
 	if int(stopSignal) == 0 {
 	if int(stopSignal) == 0 {
-		stopSignal, _ = signal.ParseSignal(signal.DefaultStopSignal)
+		stopSignal, _ = signal.ParseSignal(defaultStopSignal)
 	}
 	}
 	return int(stopSignal)
 	return int(stopSignal)
 }
 }
@@ -528,7 +528,7 @@ func (container *Container) StopTimeout() int {
 	if container.Config.StopTimeout != nil {
 	if container.Config.StopTimeout != nil {
 		return *container.Config.StopTimeout
 		return *container.Config.StopTimeout
 	}
 	}
-	return DefaultStopTimeout
+	return defaultStopTimeout
 }
 }
 
 
 // InitDNSHostConfig ensures that the dns fields are never nil.
 // InitDNSHostConfig ensures that the dns fields are never nil.

+ 3 - 3
container/container_unit_test.go

@@ -19,7 +19,7 @@ func TestContainerStopSignal(t *testing.T) {
 		Config: &container.Config{},
 		Config: &container.Config{},
 	}
 	}
 
 
-	def, err := signal.ParseSignal(signal.DefaultStopSignal)
+	def, err := signal.ParseSignal(defaultStopSignal)
 	if err != nil {
 	if err != nil {
 		t.Fatal(err)
 		t.Fatal(err)
 	}
 	}
@@ -44,8 +44,8 @@ func TestContainerStopTimeout(t *testing.T) {
 	}
 	}
 
 
 	s := c.StopTimeout()
 	s := c.StopTimeout()
-	if s != DefaultStopTimeout {
-		t.Fatalf("Expected %v, got %v", DefaultStopTimeout, s)
+	if s != defaultStopTimeout {
+		t.Fatalf("Expected %v, got %v", defaultStopTimeout, s)
 	}
 	}
 
 
 	stopTimeout := 15
 	stopTimeout := 15

+ 5 - 2
container/container_unix.go

@@ -23,9 +23,12 @@ import (
 )
 )
 
 
 const (
 const (
-	// DefaultStopTimeout sets the default time, in seconds, to wait
+	// 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.
 	// for the graceful container stop before forcefully terminating it.
-	DefaultStopTimeout = 10
+	defaultStopTimeout = 10
 
 
 	containerConfigMountPath = "/"
 	containerConfigMountPath = "/"
 	containerSecretMountPath = "/run/secrets"
 	containerSecretMountPath = "/run/secrets"

+ 5 - 2
container/container_windows.go

@@ -17,8 +17,11 @@ const (
 	containerInternalSecretMountPath = `C:\ProgramData\Docker\internal\secrets`
 	containerInternalSecretMountPath = `C:\ProgramData\Docker\internal\secrets`
 	containerInternalConfigsDirPath  = `C:\ProgramData\Docker\internal\configs`
 	containerInternalConfigsDirPath  = `C:\ProgramData\Docker\internal\configs`
 
 
-	// DefaultStopTimeout is the timeout (in seconds) for the shutdown call on a container
-	DefaultStopTimeout = 30
+	// 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
 )
 )
 
 
 // UnmountIpcMount unmounts Ipc related mounts.
 // UnmountIpcMount unmounts Ipc related mounts.

+ 4 - 3
pkg/signal/signal_deprecated.go

@@ -48,7 +48,8 @@ const (
 	// SIGPIPE is a signal sent to a process when a pipe is written to before the other end is open for reading
 	// SIGPIPE is a signal sent to a process when a pipe is written to before the other end is open for reading
 	// Deprecated: use github.com/moby/sys/signal.SIGPIPE instead
 	// Deprecated: use github.com/moby/sys/signal.SIGPIPE instead
 	SIGPIPE = msignal.SIGPIPE
 	SIGPIPE = msignal.SIGPIPE
-	// DefaultStopSignal is the syscall signal used to stop a container in unix systems.
-	// Deprecated: use github.com/moby/sys/signal.DefaultStopSignal instead
-	DefaultStopSignal = msignal.DefaultStopSignal
+
+	// DefaultStopSignal has been deprecated and removed. The default value is
+	// now defined in github.com/docker/docker/container. Clients should omit
+	// the container's stop-signal field if the default should be used.
 )
 )