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

Signed-off-by: Michael Hudson-Doyle <michael.hudson@canonical.com>
Upstream-commit: 32f24bc3c59af530196d3613dcb55ffced964de4
Component: engine
This commit is contained in:
Michael Hudson-Doyle
2016-09-19 14:27:10 +12:00
parent 2a72633153
commit 601f07305c
2 changed files with 10 additions and 0 deletions
+5
View File
@@ -1148,6 +1148,11 @@ func setupOOMScoreAdj(score int) error {
return err
}
_, err = f.WriteString(strconv.Itoa(score))
if os.IsPermission(err) {
// Setting oom_score_adj does not work in an
// unprivileged container. Ignore the error.
return nil
}
f.Close()
return err
}
@@ -435,6 +435,11 @@ func setOOMScore(pid, score int) error {
}
_, err = f.WriteString(strconv.Itoa(score))
f.Close()
if os.IsPermission(err) {
// Setting oom_score_adj does not work in an
// unprivileged container. Ignore the error.
return nil
}
return err
}