Browse code

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 <github@gone.nl>

Sebastiaan van Stijn authored on 2020/10/06 00:50:23
Showing 2 changed files
... ...
@@ -1636,6 +1636,9 @@ func setMayDetachMounts() error {
1636 1636
 }
1637 1637
 
1638 1638
 func setupOOMScoreAdj(score int) error {
1639
+	if score == 0 {
1640
+		return nil
1641
+	}
1639 1642
 	f, err := os.OpenFile("/proc/self/oom_score_adj", os.O_WRONLY, 0)
1640 1643
 	if err != nil {
1641 1644
 		return err
... ...
@@ -28,9 +28,6 @@ func (r *remote) setDefaults() {
28 28
 	if r.Debug.Address == "" {
29 29
 		r.Debug.Address = filepath.Join(r.stateDir, debugSockFile)
30 30
 	}
31
-	if r.OOMScore == 0 {
32
-		r.OOMScore = -999
33
-	}
34 31
 
35 32
 	for key, conf := range r.pluginConfs.Plugins {
36 33
 		if conf == nil {