Add bounds on max oom_score_adj value for AdjustOOMScore

oom_score_adj must be in the range -1000 to 1000. In AdjustOOMScore if containerd's score is already at the maximum value we should set that value for the shim instead of trying to set 1001 which is invalid.

Signed-off-by: Simon Kaegi <simon_kaegi@ca.ibm.com>
This commit is contained in:
Simon Kaegi
2020-12-14 12:01:04 -05:00
parent 004214808a
commit da2fd657ab
5 changed files with 23 additions and 2 deletions

View File

@@ -2043,6 +2043,10 @@ func TestShimOOMScore(t *testing.T) {
}
expectedScore := containerdScore + 1
if expectedScore > sys.OOMScoreAdjMax {
expectedScore = sys.OOMScoreAdjMax
}
// find the shim's pid
if cgroups.Mode() == cgroups.Unified {
processes, err := cg2.Procs(false)