Add the swapMemorySupport requirement to all tests related to the OOM killer. The --memory option has the subtle side effect of defaulting --memory-swap to double the value of --memory. The OOM killer doesn't kick in until the container exhausts memory+swap, and so without the memory swap cgroup the tests will timeout due to swap being effectively unlimited.
Document the default behavior of --memory-swap in the docker run man page.
Signed-off-by: Sean Christopherson <sean.j.christopherson@intel.com>
| ... | ... |
@@ -8,7 +8,7 @@ import ( |
| 8 | 8 |
) |
| 9 | 9 |
|
| 10 | 10 |
func (s *DockerSuite) TestInspectOomKilledTrue(c *check.C) {
|
| 11 |
- testRequires(c, DaemonIsLinux, memoryLimitSupport) |
|
| 11 |
+ testRequires(c, DaemonIsLinux, memoryLimitSupport, swapMemorySupport) |
|
| 12 | 12 |
|
| 13 | 13 |
name := "testoomkilled" |
| 14 | 14 |
_, exitCode, _ := dockerCmdWithError("run", "--name", name, "--memory", "32MB", "busybox", "sh", "-c", "x=a; while true; do x=$x$x$x$x; done")
|
| ... | ... |
@@ -20,7 +20,7 @@ func (s *DockerSuite) TestInspectOomKilledTrue(c *check.C) {
|
| 20 | 20 |
} |
| 21 | 21 |
|
| 22 | 22 |
func (s *DockerSuite) TestInspectOomKilledFalse(c *check.C) {
|
| 23 |
- testRequires(c, DaemonIsLinux, memoryLimitSupport) |
|
| 23 |
+ testRequires(c, DaemonIsLinux, memoryLimitSupport, swapMemorySupport) |
|
| 24 | 24 |
|
| 25 | 25 |
name := "testoomkilled" |
| 26 | 26 |
dockerCmd(c, "run", "--name", name, "--memory", "32MB", "busybox", "sh", "-c", "echo hello world") |
| ... | ... |
@@ -554,7 +554,7 @@ func (s *DockerSuite) TestRunWithInvalidPathforBlkioDeviceWriteIOps(c *check.C) |
| 554 | 554 |
} |
| 555 | 555 |
|
| 556 | 556 |
func (s *DockerSuite) TestRunOOMExitCode(c *check.C) {
|
| 557 |
- testRequires(c, oomControl) |
|
| 557 |
+ testRequires(c, memoryLimitSupport, swapMemorySupport) |
|
| 558 | 558 |
errChan := make(chan error) |
| 559 | 559 |
go func() {
|
| 560 | 560 |
defer close(errChan) |
| ... | ... |
@@ -353,7 +353,8 @@ as memory limit. |
| 353 | 353 |
**--memory-swap**="LIMIT" |
| 354 | 354 |
A limit value equal to memory plus swap. Must be used with the **-m** |
| 355 | 355 |
(**--memory**) flag. The swap `LIMIT` should always be larger than **-m** |
| 356 |
-(**--memory**) value. |
|
| 356 |
+(**--memory**) value. By default, the swap `LIMIT` will be set to double |
|
| 357 |
+the value of --memory. |
|
| 357 | 358 |
|
| 358 | 359 |
The format of `LIMIT` is `<number>[<unit>]`. Unit can be `b` (bytes), |
| 359 | 360 |
`k` (kilobytes), `m` (megabytes), or `g` (gigabytes). If you don't specify a |