Selaa lähdekoodia

Merge pull request #45315 from thaJeztah/deprecate_oom_score_adjust

daemon: deprecate --oom-score-adjust for the daemon
Sebastiaan van Stijn 2 vuotta sitten
vanhempi
commit
61656464d8

+ 2 - 1
cmd/dockerd/config_unix.go

@@ -46,7 +46,8 @@ func installConfigFlags(conf *config.Config, flags *pflag.FlagSet) error {
 	flags.StringVar(&conf.CgroupParent, "cgroup-parent", "", "Set parent cgroup for all containers")
 	flags.StringVar(&conf.CgroupParent, "cgroup-parent", "", "Set parent cgroup for all containers")
 	flags.StringVar(&conf.RemappedRoot, "userns-remap", "", "User/Group setting for user namespaces")
 	flags.StringVar(&conf.RemappedRoot, "userns-remap", "", "User/Group setting for user namespaces")
 	flags.BoolVar(&conf.LiveRestoreEnabled, "live-restore", false, "Enable live restore of docker when containers are still running")
 	flags.BoolVar(&conf.LiveRestoreEnabled, "live-restore", false, "Enable live restore of docker when containers are still running")
-	flags.IntVar(&conf.OOMScoreAdjust, "oom-score-adjust", 0, "Set the oom_score_adj for the daemon")
+	flags.IntVar(&conf.OOMScoreAdjust, "oom-score-adjust", 0, "Set the oom_score_adj for the daemon (deprecated)")
+	_ = flags.MarkDeprecated("oom-score-adjust", "and will be removed in the next release.")
 	flags.BoolVar(&conf.Init, "init", false, "Run an init in the container to forward signals and reap processes")
 	flags.BoolVar(&conf.Init, "init", false, "Run an init in the container to forward signals and reap processes")
 	flags.StringVar(&conf.InitPath, "init-path", "", "Path to the docker-init binary")
 	flags.StringVar(&conf.InitPath, "init-path", "", "Path to the docker-init binary")
 	flags.Int64Var(&conf.CPURealtimePeriod, "cpu-rt-period", 0, "Limit the CPU real-time period in microseconds for the parent cgroup for all containers (not supported with cgroups v2)")
 	flags.Int64Var(&conf.CPURealtimePeriod, "cpu-rt-period", 0, "Limit the CPU real-time period in microseconds for the parent cgroup for all containers (not supported with cgroups v2)")

+ 4 - 2
cmd/dockerd/daemon_unix.go

@@ -61,9 +61,11 @@ func (cli *DaemonCli) getPlatformContainerdDaemonOpts() ([]supervisor.DaemonOpt,
 		// TODO(thaJeztah) change this to use /proc/self/oom_score_adj instead,
 		// TODO(thaJeztah) change this to use /proc/self/oom_score_adj instead,
 		// which would allow us to set the correct score even if dockerd's score
 		// which would allow us to set the correct score even if dockerd's score
 		// was set through other means (such as systemd or "manually").
 		// was set through other means (such as systemd or "manually").
-		supervisor.WithOOMScore(cli.Config.OOMScoreAdjust),
+		supervisor.WithOOMScore(cli.Config.OOMScoreAdjust), //nolint:staticcheck // ignore SA1019 (WithOOMScore is deprecated); will be removed in the next release.
+	}
+	if cli.Config.OOMScoreAdjust != 0 {
+		logrus.Warn(`DEPRECATED: The "oom-score-adjust" config parameter and the dockerd "--oom-score-adjust" option will be removed in the next release.`)
 	}
 	}
-
 	return opts, nil
 	return opts, nil
 }
 }
 
 

+ 1 - 1
daemon/config/config_linux.go

@@ -68,7 +68,7 @@ type Config struct {
 	Ulimits              map[string]*units.Ulimit `json:"default-ulimits,omitempty"`
 	Ulimits              map[string]*units.Ulimit `json:"default-ulimits,omitempty"`
 	CPURealtimePeriod    int64                    `json:"cpu-rt-period,omitempty"`
 	CPURealtimePeriod    int64                    `json:"cpu-rt-period,omitempty"`
 	CPURealtimeRuntime   int64                    `json:"cpu-rt-runtime,omitempty"`
 	CPURealtimeRuntime   int64                    `json:"cpu-rt-runtime,omitempty"`
-	OOMScoreAdjust       int                      `json:"oom-score-adjust,omitempty"`
+	OOMScoreAdjust       int                      `json:"oom-score-adjust,omitempty"` // Deprecated: configure the daemon's oom-score-adjust using a process manager instead.
 	Init                 bool                     `json:"init,omitempty"`
 	Init                 bool                     `json:"init,omitempty"`
 	InitPath             string                   `json:"init-path,omitempty"`
 	InitPath             string                   `json:"init-path,omitempty"`
 	SeccompProfile       string                   `json:"seccomp-profile,omitempty"`
 	SeccompProfile       string                   `json:"seccomp-profile,omitempty"`

+ 3 - 0
daemon/info_unix.go

@@ -164,6 +164,9 @@ func (daemon *Daemon) fillPlatformInfo(v *types.Info, sysInfo *sysinfo.SysInfo)
 	if !v.BridgeNfIP6tables {
 	if !v.BridgeNfIP6tables {
 		v.Warnings = append(v.Warnings, "WARNING: bridge-nf-call-ip6tables is disabled")
 		v.Warnings = append(v.Warnings, "WARNING: bridge-nf-call-ip6tables is disabled")
 	}
 	}
+	if daemon.configStore.OOMScoreAdjust != 0 {
+		v.Warnings = append(v.Warnings, `DEPRECATED: The "oom-score-adjust" config parameter and the dockerd "--oom-score-adjust" option will be removed in the next release`)
+	}
 }
 }
 
 
 func (daemon *Daemon) fillPlatformVersion(v *types.Version) {
 func (daemon *Daemon) fillPlatformVersion(v *types.Version) {

+ 2 - 0
libcontainerd/supervisor/remote_daemon_options_linux.go

@@ -1,6 +1,8 @@
 package supervisor // import "github.com/docker/docker/libcontainerd/supervisor"
 package supervisor // import "github.com/docker/docker/libcontainerd/supervisor"
 
 
 // WithOOMScore defines the oom_score_adj to set for the containerd process.
 // WithOOMScore defines the oom_score_adj to set for the containerd process.
+//
+// Deprecated: setting the oom-score-adjust from the daemon itself is deprecated, and should be handled by the process-manager starting the daemon instead.
 func WithOOMScore(score int) DaemonOpt {
 func WithOOMScore(score int) DaemonOpt {
 	return func(r *remote) error {
 	return func(r *remote) error {
 		r.oomScore = score
 		r.oomScore = score