Skip to content

Commit fb96b94

Browse files
committed
daemon: remove handling for deprecated "oom-score-adjust", and produce error
This option was deprecated in 5a922dc, 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 <[email protected]>
1 parent 316781b commit fb96b94

10 files changed

Lines changed: 8 additions & 76 deletions

File tree

cmd/dockerd/config_unix.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ func installConfigFlags(conf *config.Config, flags *pflag.FlagSet) error {
4646
flags.StringVar(&conf.CgroupParent, "cgroup-parent", "", "Set parent cgroup for all containers")
4747
flags.StringVar(&conf.RemappedRoot, "userns-remap", "", "User/Group setting for user namespaces")
4848
flags.BoolVar(&conf.LiveRestoreEnabled, "live-restore", false, "Enable live restore of docker when containers are still running")
49+
// TODO(thaJeztah): Used to produce a deprecation error; remove the flag and the OOMScoreAdjust field for the next release after v25.0.0.
4950
flags.IntVar(&conf.OOMScoreAdjust, "oom-score-adjust", 0, "Set the oom_score_adj for the daemon (deprecated)")
5051
_ = flags.MarkDeprecated("oom-score-adjust", "and will be removed in the next release.")
5152
flags.BoolVar(&conf.Init, "init", false, "Run an init in the container to forward signals and reap processes")

cmd/dockerd/daemon.go

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -629,11 +629,7 @@ func initMiddlewares(s *apiserver.Server, cfg *config.Config, pluginStore plugin
629629
}
630630

631631
func (cli *DaemonCli) getContainerdDaemonOpts() ([]supervisor.DaemonOpt, error) {
632-
opts, err := cli.getPlatformContainerdDaemonOpts()
633-
if err != nil {
634-
return nil, err
635-
}
636-
632+
var opts []supervisor.DaemonOpt
637633
if cli.Debug {
638634
opts = append(opts, supervisor.WithLogLevel("debug"))
639635
} else {

cmd/dockerd/daemon_unix.go

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -56,19 +56,6 @@ func setDefaultUmask() error {
5656
return nil
5757
}
5858

59-
func (cli *DaemonCli) getPlatformContainerdDaemonOpts() ([]supervisor.DaemonOpt, error) {
60-
opts := []supervisor.DaemonOpt{
61-
// TODO(thaJeztah) change this to use /proc/self/oom_score_adj instead,
62-
// which would allow us to set the correct score even if dockerd's score
63-
// was set through other means (such as systemd or "manually").
64-
supervisor.WithOOMScore(cli.Config.OOMScoreAdjust), //nolint:staticcheck // ignore SA1019 (WithOOMScore is deprecated); will be removed in the next release.
65-
}
66-
if cli.Config.OOMScoreAdjust != 0 {
67-
logrus.Warn(`DEPRECATED: The "oom-score-adjust" config parameter and the dockerd "--oom-score-adjust" option will be removed in the next release.`)
68-
}
69-
return opts, nil
70-
}
71-
7259
// setupConfigReloadTrap configures the SIGHUP signal to reload the configuration.
7360
func (cli *DaemonCli) setupConfigReloadTrap() {
7461
c := make(chan os.Signal, 1)

cmd/dockerd/daemon_windows.go

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ import (
77
"time"
88

99
"github.com/docker/docker/daemon/config"
10-
"github.com/docker/docker/libcontainerd/supervisor"
1110
"github.com/docker/docker/pkg/system"
1211
"github.com/sirupsen/logrus"
1312
"golang.org/x/sys/windows"
@@ -52,10 +51,6 @@ func notifyShutdown(err error) {
5251
}
5352
}
5453

55-
func (cli *DaemonCli) getPlatformContainerdDaemonOpts() ([]supervisor.DaemonOpt, error) {
56-
return nil, nil
57-
}
58-
5954
// setupConfigReloadTrap configures a Win32 event to reload the configuration.
6055
func (cli *DaemonCli) setupConfigReloadTrap() {
6156
go func() {

daemon/config/config_linux.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -184,6 +184,9 @@ func verifyDefaultCgroupNsMode(mode string) error {
184184

185185
// ValidatePlatformConfig checks if any platform-specific configuration settings are invalid.
186186
func (conf *Config) ValidatePlatformConfig() error {
187+
if conf.OOMScoreAdjust != 0 {
188+
return errors.New(`DEPRECATED: The "oom-score-adjust" config parameter and the dockerd "--oom-score-adjust" options have been removed.`)
189+
}
187190
if err := verifyDefaultIpcMode(conf.IpcMode); err != nil {
188191
return err
189192
}

daemon/daemon.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -767,8 +767,8 @@ func NewDaemon(ctx context.Context, config *config.Config, pluginStore *plugin.S
767767
return nil, err
768768
}
769769
rootIDs := idMapping.RootPair()
770-
if err := setupDaemonProcess(config); err != nil {
771-
return nil, err
770+
if err := setMayDetachMounts(); err != nil {
771+
logrus.WithError(err).Warn("Could not set may_detach_mounts kernel parameter")
772772
}
773773

774774
// set up the tmpDir to use a canonical path

daemon/daemon_unix.go

Lines changed: 0 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -1415,18 +1415,6 @@ func (daemon *Daemon) setDefaultIsolation() error {
14151415
return nil
14161416
}
14171417

1418-
// setupDaemonProcess sets various settings for the daemon's process
1419-
func setupDaemonProcess(config *config.Config) error {
1420-
// setup the daemons oom_score_adj
1421-
if err := setupOOMScoreAdj(config.OOMScoreAdjust); err != nil {
1422-
return err
1423-
}
1424-
if err := setMayDetachMounts(); err != nil {
1425-
logrus.WithError(err).Warn("Could not set may_detach_mounts kernel parameter")
1426-
}
1427-
return nil
1428-
}
1429-
14301418
// This is used to allow removal of mountpoints that may be mounted in other
14311419
// namespaces on RHEL based kernels starting from RHEL 7.4.
14321420
// Without this setting, removals on these RHEL based kernels may fail with
@@ -1456,30 +1444,6 @@ func setMayDetachMounts() error {
14561444
return err
14571445
}
14581446

1459-
func setupOOMScoreAdj(score int) error {
1460-
if score == 0 {
1461-
return nil
1462-
}
1463-
f, err := os.OpenFile("/proc/self/oom_score_adj", os.O_WRONLY, 0)
1464-
if err != nil {
1465-
return err
1466-
}
1467-
defer f.Close()
1468-
stringScore := strconv.Itoa(score)
1469-
_, err = f.WriteString(stringScore)
1470-
if os.IsPermission(err) {
1471-
// Setting oom_score_adj does not work in an
1472-
// unprivileged container. Ignore the error, but log
1473-
// it if we appear not to be in that situation.
1474-
if !userns.RunningInUserNS() {
1475-
logrus.Debugf("Permission denied writing %q to /proc/self/oom_score_adj", stringScore)
1476-
}
1477-
return nil
1478-
}
1479-
1480-
return err
1481-
}
1482-
14831447
func (daemon *Daemon) initCPURtController(mnt, path string) error {
14841448
if path == "/" || path == "." {
14851449
return nil

daemon/daemon_windows.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -548,7 +548,7 @@ func (daemon *Daemon) setDefaultIsolation() error {
548548
return nil
549549
}
550550

551-
func setupDaemonProcess(config *config.Config) error {
551+
func setMayDetachMounts() error {
552552
return nil
553553
}
554554

daemon/info_unix.go

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -164,9 +164,6 @@ func (daemon *Daemon) fillPlatformInfo(v *types.Info, sysInfo *sysinfo.SysInfo)
164164
if !v.BridgeNfIP6tables {
165165
v.Warnings = append(v.Warnings, "WARNING: bridge-nf-call-ip6tables is disabled")
166166
}
167-
if daemon.configStore.OOMScoreAdjust != 0 {
168-
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`)
169-
}
170167
}
171168

172169
func (daemon *Daemon) fillPlatformVersion(v *types.Version) {

libcontainerd/supervisor/remote_daemon_options_linux.go

Lines changed: 0 additions & 11 deletions
This file was deleted.

0 commit comments

Comments
 (0)