Browse code

Ignore failure to set oom_score_adj, as happens in an unprivileged container.

Signed-off-by: Michael Hudson-Doyle <michael.hudson@canonical.com>

Michael Hudson-Doyle authored on 2016/09/19 11:27:10
Showing 2 changed files
... ...
@@ -1148,6 +1148,11 @@ func setupOOMScoreAdj(score int) error {
1148 1148
 		return err
1149 1149
 	}
1150 1150
 	_, err = f.WriteString(strconv.Itoa(score))
1151
+	if os.IsPermission(err) {
1152
+		// Setting oom_score_adj does not work in an
1153
+		// unprivileged container. Ignore the error.
1154
+		return nil
1155
+	}
1151 1156
 	f.Close()
1152 1157
 	return err
1153 1158
 }
... ...
@@ -435,6 +435,11 @@ func setOOMScore(pid, score int) error {
435 435
 	}
436 436
 	_, err = f.WriteString(strconv.Itoa(score))
437 437
 	f.Close()
438
+	if os.IsPermission(err) {
439
+		// Setting oom_score_adj does not work in an
440
+		// unprivileged container. Ignore the error.
441
+		return nil
442
+	}
438 443
 	return err
439 444
 }
440 445