summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSebastiaan van Stijn <github@gone.nl>2023-05-06 15:04:41 +0200
committerSebastiaan van Stijn <github@gone.nl>2023-05-06 16:36:17 +0200
commitfb96b94ed00aa4f200dc03642bc46d4289eb6860 (patch)
tree2b8288902106d1f148b08177c825188e8e1ec974
parent316781be48bb72770e07d41d469c79ef4194483b (diff)
downloaddocker-fb96b94ed00aa4f200dc03642bc46d4289eb6860.tar.gz
daemon: remove handling for deprecated "oom-score-adjust", and produce error
This option was deprecated in 5a922dc162bbe0a03450165da4e6aceca55073d4, which is part of the v24.0.0 release, so we can remove it from master. This patch; - adds a check to ValidatePlatformConfig, and produces a fatal error if oom-score-adjust is set - removes the deprecated libcontainerd/supervisor.WithOOMScore - removes the warning from docker info With this patch: dockerd --oom-score-adjust=-500 --validate Flag --oom-score-adjust has been deprecated, and will be removed in the next release. unable to configure the Docker daemon with file /etc/docker/daemon.json: merged configuration validation from file and command line flags failed: DEPRECATED: The "oom-score-adjust" config parameter and the dockerd "--oom-score-adjust" options have been removed. And when using `daemon.json`: dockerd --validate unable to configure the Docker daemon with file /etc/docker/daemon.json: merged configuration validation from file and command line flags failed: DEPRECATED: The "oom-score-adjust" config parameter and the dockerd "--oom-score-adjust" options have been removed. Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
-rw-r--r--cmd/dockerd/config_unix.go1
-rw-r--r--cmd/dockerd/daemon.go6
-rw-r--r--cmd/dockerd/daemon_unix.go13
-rw-r--r--cmd/dockerd/daemon_windows.go5
-rw-r--r--daemon/config/config_linux.go3
-rw-r--r--daemon/daemon.go4
-rw-r--r--daemon/daemon_unix.go36
-rw-r--r--daemon/daemon_windows.go2
-rw-r--r--daemon/info_unix.go3
-rw-r--r--libcontainerd/supervisor/remote_daemon_options_linux.go11
10 files changed, 8 insertions, 76 deletions
diff --git a/cmd/dockerd/config_unix.go b/cmd/dockerd/config_unix.go
index 95c0dcd74a..f7aac2c0f3 100644
--- a/cmd/dockerd/config_unix.go
+++ b/cmd/dockerd/config_unix.go
@@ -46,6 +46,7 @@ func installConfigFlags(conf *config.Config, flags *pflag.FlagSet) error {
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.BoolVar(&conf.LiveRestoreEnabled, "live-restore", false, "Enable live restore of docker when containers are still running")
+ // TODO(thaJeztah): Used to produce a deprecation error; remove the flag and the OOMScoreAdjust field for the next release after v25.0.0.
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")
diff --git a/cmd/dockerd/daemon.go b/cmd/dockerd/daemon.go
index ebd5318520..ebfa858207 100644
--- a/cmd/dockerd/daemon.go
+++ b/cmd/dockerd/daemon.go
@@ -629,11 +629,7 @@ func initMiddlewares(s *apiserver.Server, cfg *config.Config, pluginStore plugin
}
func (cli *DaemonCli) getContainerdDaemonOpts() ([]supervisor.DaemonOpt, error) {
- opts, err := cli.getPlatformContainerdDaemonOpts()
- if err != nil {
- return nil, err
- }
-
+ var opts []supervisor.DaemonOpt
if cli.Debug {
opts = append(opts, supervisor.WithLogLevel("debug"))
} else {
diff --git a/cmd/dockerd/daemon_unix.go b/cmd/dockerd/daemon_unix.go
index cd239522df..c25cddb7bc 100644
--- a/cmd/dockerd/daemon_unix.go
+++ b/cmd/dockerd/daemon_unix.go
@@ -56,19 +56,6 @@ func setDefaultUmask() error {
return nil
}
-func (cli *DaemonCli) getPlatformContainerdDaemonOpts() ([]supervisor.DaemonOpt, error) {
- opts := []supervisor.DaemonOpt{
- // 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
- // was set through other means (such as systemd or "manually").
- 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
-}
-
// setupConfigReloadTrap configures the SIGHUP signal to reload the configuration.
func (cli *DaemonCli) setupConfigReloadTrap() {
c := make(chan os.Signal, 1)
diff --git a/cmd/dockerd/daemon_windows.go b/cmd/dockerd/daemon_windows.go
index 729b4da03d..f139b926b3 100644
--- a/cmd/dockerd/daemon_windows.go
+++ b/cmd/dockerd/daemon_windows.go
@@ -7,7 +7,6 @@ import (
"time"
"github.com/docker/docker/daemon/config"
- "github.com/docker/docker/libcontainerd/supervisor"
"github.com/docker/docker/pkg/system"
"github.com/sirupsen/logrus"
"golang.org/x/sys/windows"
@@ -52,10 +51,6 @@ func notifyShutdown(err error) {
}
}
-func (cli *DaemonCli) getPlatformContainerdDaemonOpts() ([]supervisor.DaemonOpt, error) {
- return nil, nil
-}
-
// setupConfigReloadTrap configures a Win32 event to reload the configuration.
func (cli *DaemonCli) setupConfigReloadTrap() {
go func() {
diff --git a/daemon/config/config_linux.go b/daemon/config/config_linux.go
index 085d6fe478..58a86491f2 100644
--- a/daemon/config/config_linux.go
+++ b/daemon/config/config_linux.go
@@ -184,6 +184,9 @@ func verifyDefaultCgroupNsMode(mode string) error {
// ValidatePlatformConfig checks if any platform-specific configuration settings are invalid.
func (conf *Config) ValidatePlatformConfig() error {
+ if conf.OOMScoreAdjust != 0 {
+ return errors.New(`DEPRECATED: The "oom-score-adjust" config parameter and the dockerd "--oom-score-adjust" options have been removed.`)
+ }
if err := verifyDefaultIpcMode(conf.IpcMode); err != nil {
return err
}
diff --git a/daemon/daemon.go b/daemon/daemon.go
index 3b9b5244ec..597bf50ee4 100644
--- a/daemon/daemon.go
+++ b/daemon/daemon.go
@@ -767,8 +767,8 @@ func NewDaemon(ctx context.Context, config *config.Config, pluginStore *plugin.S
return nil, err
}
rootIDs := idMapping.RootPair()
- if err := setupDaemonProcess(config); err != nil {
- return nil, err
+ if err := setMayDetachMounts(); err != nil {
+ logrus.WithError(err).Warn("Could not set may_detach_mounts kernel parameter")
}
// set up the tmpDir to use a canonical path
diff --git a/daemon/daemon_unix.go b/daemon/daemon_unix.go
index 4b504c871e..1638b5ad94 100644
--- a/daemon/daemon_unix.go
+++ b/daemon/daemon_unix.go
@@ -1415,18 +1415,6 @@ func (daemon *Daemon) setDefaultIsolation() error {
return nil
}
-// setupDaemonProcess sets various settings for the daemon's process
-func setupDaemonProcess(config *config.Config) error {
- // setup the daemons oom_score_adj
- if err := setupOOMScoreAdj(config.OOMScoreAdjust); err != nil {
- return err
- }
- if err := setMayDetachMounts(); err != nil {
- logrus.WithError(err).Warn("Could not set may_detach_mounts kernel parameter")
- }
- return nil
-}
-
// This is used to allow removal of mountpoints that may be mounted in other
// namespaces on RHEL based kernels starting from RHEL 7.4.
// Without this setting, removals on these RHEL based kernels may fail with
@@ -1456,30 +1444,6 @@ func setMayDetachMounts() error {
return err
}
-func setupOOMScoreAdj(score int) error {
- if score == 0 {
- return nil
- }
- f, err := os.OpenFile("/proc/self/oom_score_adj", os.O_WRONLY, 0)
- if err != nil {
- return err
- }
- defer f.Close()
- stringScore := strconv.Itoa(score)
- _, err = f.WriteString(stringScore)
- if os.IsPermission(err) {
- // Setting oom_score_adj does not work in an
- // unprivileged container. Ignore the error, but log
- // it if we appear not to be in that situation.
- if !userns.RunningInUserNS() {
- logrus.Debugf("Permission denied writing %q to /proc/self/oom_score_adj", stringScore)
- }
- return nil
- }
-
- return err
-}
-
func (daemon *Daemon) initCPURtController(mnt, path string) error {
if path == "/" || path == "." {
return nil
diff --git a/daemon/daemon_windows.go b/daemon/daemon_windows.go
index 8cbcc20132..b6ced4af02 100644
--- a/daemon/daemon_windows.go
+++ b/daemon/daemon_windows.go
@@ -548,7 +548,7 @@ func (daemon *Daemon) setDefaultIsolation() error {
return nil
}
-func setupDaemonProcess(config *config.Config) error {
+func setMayDetachMounts() error {
return nil
}
diff --git a/daemon/info_unix.go b/daemon/info_unix.go
index f94ed4499b..e48a81088c 100644
--- a/daemon/info_unix.go
+++ b/daemon/info_unix.go
@@ -164,9 +164,6 @@ func (daemon *Daemon) fillPlatformInfo(v *types.Info, sysInfo *sysinfo.SysInfo)
if !v.BridgeNfIP6tables {
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) {
diff --git a/libcontainerd/supervisor/remote_daemon_options_linux.go b/libcontainerd/supervisor/remote_daemon_options_linux.go
deleted file mode 100644
index 3ae0d6cc6c..0000000000
--- a/libcontainerd/supervisor/remote_daemon_options_linux.go
+++ /dev/null
@@ -1,11 +0,0 @@
-package supervisor // import "github.com/docker/docker/libcontainerd/supervisor"
-
-// 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 {
- return func(r *remote) error {
- r.oomScore = score
- return nil
- }
-}