From 2b8e68ef06ca3daf2b0e17e51ba72999773b6270 Mon Sep 17 00:00:00 2001 From: Sebastiaan van Stijn Date: Mon, 5 Oct 2020 18:55:43 +0200 Subject: [PATCH 1/2] dockerd: remove default -500 oom-score-adjust dockerd currently sets the oom-score-adjust itself. This functionality was added when we did not yet run dockerd as a systemd service. Now that we do, it's better to instead have systemd handle this. Keeping the option itself for situations where dockerd is started manually or without using systemd. Signed-off-by: Sebastiaan van Stijn --- cmd/dockerd/config_unix.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cmd/dockerd/config_unix.go b/cmd/dockerd/config_unix.go index 7ee3ec611e..ec417143e7 100644 --- a/cmd/dockerd/config_unix.go +++ b/cmd/dockerd/config_unix.go @@ -52,7 +52,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") - flags.IntVar(&conf.OOMScoreAdjust, "oom-score-adjust", -500, "Set the oom_score_adj for the daemon") + flags.IntVar(&conf.OOMScoreAdjust, "oom-score-adjust", 0, "Set the oom_score_adj for the daemon") 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.Int64Var(&conf.CPURealtimePeriod, "cpu-rt-period", 0, "Limit the CPU real-time period in microseconds for the parent cgroup for all containers") From 561b8014c022bede412aee47e89cc11b648316ac Mon Sep 17 00:00:00 2001 From: Sebastiaan van Stijn Date: Mon, 5 Oct 2020 20:04:52 +0200 Subject: [PATCH 2/2] testutil: set -500 OOM score for test daemons Signed-off-by: Sebastiaan van Stijn --- testutil/daemon/daemon.go | 2 ++ testutil/daemon/ops.go | 7 +++++++ 2 files changed, 9 insertions(+) diff --git a/testutil/daemon/daemon.go b/testutil/daemon/daemon.go index 135962669e..3b9f039c8a 100644 --- a/testutil/daemon/daemon.go +++ b/testutil/daemon/daemon.go @@ -88,6 +88,7 @@ type Daemon struct { DefaultAddrPool []string SubnetSize uint32 DataPathPort uint32 + OOMScoreAdjust int // cached information CachedInfo types.Info } @@ -206,6 +207,7 @@ func New(t testing.TB, ops ...Option) *Daemon { } ops = append(ops, WithRootlessUser("unprivilegeduser")) } + ops = append(ops, WithOOMScoreAdjust(-500)) d, err := NewDaemon(dest, ops...) assert.NilError(t, err, "could not create daemon at %q", dest) diff --git a/testutil/daemon/ops.go b/testutil/daemon/ops.go index 66d169d1de..c977dcef44 100644 --- a/testutil/daemon/ops.go +++ b/testutil/daemon/ops.go @@ -115,3 +115,10 @@ func WithRootlessUser(username string) Option { d.rootlessUser = u } } + +// WithOOMScoreAdjust sets OOM score for the daemon +func WithOOMScoreAdjust(score int) Option { + return func(d *Daemon) { + d.OOMScoreAdjust = score + } +}