Selaa lähdekoodia

Merge pull request #41528 from thaJeztah/remove_default_oom_score_adj

Brian Goff 4 vuotta sitten
vanhempi
commit
e180525bb4
3 muutettua tiedostoa jossa 10 lisäystä ja 1 poistoa
  1. 1 1
      cmd/dockerd/config_unix.go
  2. 2 0
      testutil/daemon/daemon.go
  3. 7 0
      testutil/daemon/ops.go

+ 1 - 1
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.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", -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.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")
 	flags.Int64Var(&conf.CPURealtimePeriod, "cpu-rt-period", 0, "Limit the CPU real-time period in microseconds for the parent cgroup for all containers")

+ 2 - 0
testutil/daemon/daemon.go

@@ -88,6 +88,7 @@ type Daemon struct {
 	DefaultAddrPool []string
 	DefaultAddrPool []string
 	SubnetSize      uint32
 	SubnetSize      uint32
 	DataPathPort    uint32
 	DataPathPort    uint32
+	OOMScoreAdjust  int
 	// cached information
 	// cached information
 	CachedInfo types.Info
 	CachedInfo types.Info
 }
 }
@@ -206,6 +207,7 @@ func New(t testing.TB, ops ...Option) *Daemon {
 		}
 		}
 		ops = append(ops, WithRootlessUser("unprivilegeduser"))
 		ops = append(ops, WithRootlessUser("unprivilegeduser"))
 	}
 	}
+	ops = append(ops, WithOOMScoreAdjust(-500))
 
 
 	d, err := NewDaemon(dest, ops...)
 	d, err := NewDaemon(dest, ops...)
 	assert.NilError(t, err, "could not create daemon at %q", dest)
 	assert.NilError(t, err, "could not create daemon at %q", dest)

+ 7 - 0
testutil/daemon/ops.go

@@ -115,3 +115,10 @@ func WithRootlessUser(username string) Option {
 		d.rootlessUser = u
 		d.rootlessUser = u
 	}
 	}
 }
 }
+
+// WithOOMScoreAdjust sets OOM score for the daemon
+func WithOOMScoreAdjust(score int) Option {
+	return func(d *Daemon) {
+		d.OOMScoreAdjust = score
+	}
+}