mirror of
https://github.com/moby/moby.git
synced 2025-07-29 07:21:35 +03:00
Add OomScoreAdj to configure container oom killer preferences
libcontainer v0.0.4 introduces setting `/proc/self/oom_score_adj` to better tune oom killing preferences for container process. This patch simply integrates OomScoreAdj libcontainer's config option and adjust the cli with this new option. Signed-off-by: Antonio Murdaca <amurdaca@redhat.com> Signed-off-by: Antonio Murdaca <runcom@redhat.com>
This commit is contained in:
committed by
Antonio Murdaca
parent
dd25d2c3db
commit
d3af7f283d
@ -1553,3 +1553,34 @@ func (s *DockerSuite) TestPostContainersCreateWithWrongCpusetValues(c *check.C)
|
||||
expected = "Invalid value 42-3,1-- for cpuset mems.\n"
|
||||
c.Assert(string(body), check.Equals, expected, check.Commentf("Expected output to contain %q, got %q", expected, string(body)))
|
||||
}
|
||||
|
||||
// check validation is done daemon side and not only in cli
|
||||
func (s *DockerSuite) TestPostContainersCreateWithOomScoreAdjInvalidRange(c *check.C) {
|
||||
testRequires(c, DaemonIsLinux)
|
||||
|
||||
config := struct {
|
||||
Image string
|
||||
OomScoreAdj int
|
||||
}{"busybox", 1001}
|
||||
name := "oomscoreadj-over"
|
||||
status, b, err := sockRequest("POST", "/containers/create?name="+name, config)
|
||||
c.Assert(err, check.IsNil)
|
||||
c.Assert(status, check.Equals, http.StatusInternalServerError)
|
||||
expected := "Invalid value 1001, range for oom score adj is [-1000, 1000]."
|
||||
if !strings.Contains(string(b), expected) {
|
||||
c.Fatalf("Expected output to contain %q, got %q", expected, string(b))
|
||||
}
|
||||
|
||||
config = struct {
|
||||
Image string
|
||||
OomScoreAdj int
|
||||
}{"busybox", -1001}
|
||||
name = "oomscoreadj-low"
|
||||
status, b, err = sockRequest("POST", "/containers/create?name="+name, config)
|
||||
c.Assert(err, check.IsNil)
|
||||
c.Assert(status, check.Equals, http.StatusInternalServerError)
|
||||
expected = "Invalid value -1001, range for oom score adj is [-1000, 1000]."
|
||||
if !strings.Contains(string(b), expected) {
|
||||
c.Fatalf("Expected output to contain %q, got %q", expected, string(b))
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user