-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Set OOMKilled state on any OOM event
This restores the behavior that existed prior to moby#16235 for setting OOMKilled, while retaining the additional benefits it introduced around emitting the oom event. This also adds a test for the most obvious OOM cases which would have caught this regression. Fixes moby#18510 Signed-off-by: Euan <[email protected]>
- Loading branch information
Showing
3 changed files
with
51 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
// +build !windows | ||
|
||
package main | ||
|
||
import ( | ||
"github.com/docker/docker/pkg/integration/checker" | ||
"github.com/go-check/check" | ||
) | ||
|
||
func (s *DockerSuite) TestInspectOomKilledTrue(c *check.C) { | ||
testRequires(c, DaemonIsLinux, memoryLimitSupport) | ||
|
||
name := "testoomkilled" | ||
_, exitCode, _ := dockerCmdWithError("run", "--name", name, "-m", "10MB", "busybox", "sh", "-c", "x=a; while true; do x=$x$x$x$x; done") | ||
|
||
c.Assert(exitCode, checker.Equals, 137, check.Commentf("OOM exit should be 137")) | ||
|
||
oomKilled, err := inspectField(name, "State.OOMKilled") | ||
c.Assert(oomKilled, checker.Equals, "true") | ||
c.Assert(err, checker.IsNil) | ||
} | ||
|
||
func (s *DockerSuite) TestInspectOomKilledFalse(c *check.C) { | ||
testRequires(c, DaemonIsLinux, memoryLimitSupport) | ||
|
||
name := "testoomkilled" | ||
dockerCmd(c, "run", "--name", name, "-m", "10MB", "busybox", "sh", "-c", "echo hello world") | ||
|
||
oomKilled, err := inspectField(name, "State.OOMKilled") | ||
c.Assert(oomKilled, checker.Equals, "false") | ||
c.Assert(err, checker.IsNil) | ||
} |