瀏覽代碼

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 9 年之前
父節點
當前提交
32f24bc3c5
共有 2 個文件被更改,包括 10 次插入0 次删除
  1. 5 0
      daemon/daemon_unix.go
  2. 5 0
      libcontainerd/remote_linux.go

+ 5 - 0
daemon/daemon_unix.go

@@ -1148,6 +1148,11 @@ func setupOOMScoreAdj(score int) error {
 		return err
 		return err
 	}
 	}
 	_, err = f.WriteString(strconv.Itoa(score))
 	_, 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()
 	f.Close()
 	return err
 	return err
 }
 }

+ 5 - 0
libcontainerd/remote_linux.go

@@ -435,6 +435,11 @@ func setOOMScore(pid, score int) error {
 	}
 	}
 	_, err = f.WriteString(strconv.Itoa(score))
 	_, err = f.WriteString(strconv.Itoa(score))
 	f.Close()
 	f.Close()
+	if os.IsPermission(err) {
+		// Setting oom_score_adj does not work in an
+		// unprivileged container. Ignore the error.
+		return nil
+	}
 	return err
 	return err
 }
 }