mirror of
https://github.com/opencontainers/runc.git
synced 2026-07-11 06:03:57 +08:00
libcontainer: handle unset oomScoreAdj corectly
Previously if oomScoreAdj was not set in config.json we would implicitly set oom_score_adj to 0. This is not allowed according to the spec: > If oomScoreAdj is not set, the runtime MUST NOT change the value of > oom_score_adj. Change this so that we do not modify oom_score_adj if oomScoreAdj is not present in the configuration. While this modifies our internal configuration types, the on-disk format is still compatible. Signed-off-by: Aleksa Sarai <asarai@suse.de>
This commit is contained in:
@@ -1075,7 +1075,7 @@ func TestOomScoreAdj(t *testing.T) {
|
||||
defer remove(rootfs)
|
||||
|
||||
config := newTemplateConfig(rootfs)
|
||||
config.OomScoreAdj = 200
|
||||
config.OomScoreAdj = ptrInt(200)
|
||||
|
||||
factory, err := libcontainer.New(root, libcontainer.Cgroupfs)
|
||||
ok(t, err)
|
||||
@@ -1100,8 +1100,8 @@ func TestOomScoreAdj(t *testing.T) {
|
||||
outputOomScoreAdj := strings.TrimSpace(string(stdout.Bytes()))
|
||||
|
||||
// Check that the oom_score_adj matches the value that was set as part of config.
|
||||
if outputOomScoreAdj != strconv.Itoa(config.OomScoreAdj) {
|
||||
t.Fatalf("Expected oom_score_adj %d; got %q", config.OomScoreAdj, outputOomScoreAdj)
|
||||
if outputOomScoreAdj != strconv.Itoa(*config.OomScoreAdj) {
|
||||
t.Fatalf("Expected oom_score_adj %d; got %q", *config.OomScoreAdj, outputOomScoreAdj)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user