From cf7a5be0f2ee8bb4a3f7961682e13b89bc625299 Mon Sep 17 00:00:00 2001 From: Sebastiaan van Stijn Date: Mon, 5 Oct 2020 17:50:23 +0200 Subject: [PATCH] daemon: don't adjust oom-score if score is 0 This patch makes two changes if --oom-score-adj is set to 0 - do not adjust the oom-score-adjust cgroup for dockerd - do not set the hard-coded -999 score for containerd if containerd is running as child process Before this change: oom-score-adj | dockerd | containerd as child-process --------------|---------------|---------------------------- - | -500 | -500 (same as dockerd) -100 | -100 | -100 (same as dockerd) 0 | 0 | -999 (hard-coded default) With this change: oom-score-adj | dockerd | containerd as child-process --------------|---------------|---------------------------- - | -500 | -500 (same as dockerd) -100 | -100 | -100 (same as dockerd) 0 | not adjusted | not adjusted Signed-off-by: Sebastiaan van Stijn --- daemon/daemon_unix.go | 3 +++ libcontainerd/supervisor/remote_daemon_linux.go | 3 --- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/daemon/daemon_unix.go b/daemon/daemon_unix.go index 446c71f3a6..efe8796d8d 100644 --- a/daemon/daemon_unix.go +++ b/daemon/daemon_unix.go @@ -1636,6 +1636,9 @@ func setMayDetachMounts() error { } 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 diff --git a/libcontainerd/supervisor/remote_daemon_linux.go b/libcontainerd/supervisor/remote_daemon_linux.go index 799399c07b..d229881a62 100644 --- a/libcontainerd/supervisor/remote_daemon_linux.go +++ b/libcontainerd/supervisor/remote_daemon_linux.go @@ -28,9 +28,6 @@ func (r *remote) setDefaults() { if r.Debug.Address == "" { r.Debug.Address = filepath.Join(r.stateDir, debugSockFile) } - if r.OOMScore == 0 { - r.OOMScore = -999 - } for key, conf := range r.pluginConfs.Plugins { if conf == nil {