Starting with runc v1.0.0-rc94, runc no longer supports KernelMemory.
https://github.com/opencontainers/runc/commit/52390d68040637dfc77f9fda6bbe70952423d380
Signed-off-by: Akihiro Suda <akihiro.suda.cz@hco.ntt.co.jp>
(cherry picked from commit 2f0d6664a11f70a27ff5835f60e6d4408681bd75)
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
| ... | ... |
@@ -495,33 +495,6 @@ func (s *DockerSuite) TestRunWithInvalidCpuPeriod(c *testing.T) {
|
| 495 | 495 |
assert.Assert(c, strings.Contains(out, expected)) |
| 496 | 496 |
} |
| 497 | 497 |
|
| 498 |
-func (s *DockerSuite) TestRunWithKernelMemory(c *testing.T) {
|
|
| 499 |
- testRequires(c, DaemonIsLinux, kernelMemorySupport) |
|
| 500 |
- |
|
| 501 |
- file := "/sys/fs/cgroup/memory/memory.kmem.limit_in_bytes" |
|
| 502 |
- cli.DockerCmd(c, "run", "--kernel-memory", "50M", "--name", "test1", "busybox", "cat", file).Assert(c, icmd.Expected{
|
|
| 503 |
- Out: "52428800", |
|
| 504 |
- }) |
|
| 505 |
- |
|
| 506 |
- cli.InspectCmd(c, "test1", cli.Format(".HostConfig.KernelMemory")).Assert(c, icmd.Expected{
|
|
| 507 |
- Out: "52428800", |
|
| 508 |
- }) |
|
| 509 |
-} |
|
| 510 |
- |
|
| 511 |
-func (s *DockerSuite) TestRunWithInvalidKernelMemory(c *testing.T) {
|
|
| 512 |
- testRequires(c, DaemonIsLinux, kernelMemorySupport) |
|
| 513 |
- |
|
| 514 |
- out, _, err := dockerCmdWithError("run", "--kernel-memory", "2M", "busybox", "true")
|
|
| 515 |
- assert.ErrorContains(c, err, "") |
|
| 516 |
- expected := "Minimum kernel memory limit allowed is 4MB" |
|
| 517 |
- assert.Assert(c, strings.Contains(out, expected)) |
|
| 518 |
- |
|
| 519 |
- out, _, err = dockerCmdWithError("run", "--kernel-memory", "-16m", "--name", "test2", "busybox", "echo", "test")
|
|
| 520 |
- assert.ErrorContains(c, err, "") |
|
| 521 |
- expected = "invalid size" |
|
| 522 |
- assert.Assert(c, strings.Contains(out, expected)) |
|
| 523 |
-} |
|
| 524 |
- |
|
| 525 | 498 |
func (s *DockerSuite) TestRunWithCPUShares(c *testing.T) {
|
| 526 | 499 |
testRequires(c, cpuShare) |
| 527 | 500 |
|
| ... | ... |
@@ -14,7 +14,6 @@ import ( |
| 14 | 14 |
"github.com/creack/pty" |
| 15 | 15 |
"github.com/docker/docker/api/types" |
| 16 | 16 |
"github.com/docker/docker/client" |
| 17 |
- "github.com/docker/docker/pkg/parsers/kernel" |
|
| 18 | 17 |
"github.com/docker/docker/testutil/request" |
| 19 | 18 |
"gotest.tools/v3/assert" |
| 20 | 19 |
) |
| ... | ... |
@@ -122,67 +121,6 @@ func (s *DockerSuite) TestUpdateContainerWithoutFlags(c *testing.T) {
|
| 122 | 122 |
assert.ErrorContains(c, err, "") |
| 123 | 123 |
} |
| 124 | 124 |
|
| 125 |
-func (s *DockerSuite) TestUpdateKernelMemory(c *testing.T) {
|
|
| 126 |
- testRequires(c, DaemonIsLinux, kernelMemorySupport) |
|
| 127 |
- |
|
| 128 |
- name := "test-update-container" |
|
| 129 |
- dockerCmd(c, "run", "-d", "--name", name, "--kernel-memory", "50M", "busybox", "top") |
|
| 130 |
- dockerCmd(c, "update", "--kernel-memory", "100M", name) |
|
| 131 |
- |
|
| 132 |
- assert.Equal(c, inspectField(c, name, "HostConfig.KernelMemory"), "104857600") |
|
| 133 |
- |
|
| 134 |
- file := "/sys/fs/cgroup/memory/memory.kmem.limit_in_bytes" |
|
| 135 |
- out, _ := dockerCmd(c, "exec", name, "cat", file) |
|
| 136 |
- assert.Equal(c, strings.TrimSpace(out), "104857600") |
|
| 137 |
-} |
|
| 138 |
- |
|
| 139 |
-func (s *DockerSuite) TestUpdateKernelMemoryUninitialized(c *testing.T) {
|
|
| 140 |
- testRequires(c, DaemonIsLinux, kernelMemorySupport) |
|
| 141 |
- |
|
| 142 |
- isNewKernel := CheckKernelVersion(4, 6, 0) |
|
| 143 |
- name := "test-update-container" |
|
| 144 |
- dockerCmd(c, "run", "-d", "--name", name, "busybox", "top") |
|
| 145 |
- _, _, err := dockerCmdWithError("update", "--kernel-memory", "100M", name)
|
|
| 146 |
- // Update kernel memory to a running container without kernel memory initialized |
|
| 147 |
- // is not allowed before kernel version 4.6. |
|
| 148 |
- if !isNewKernel {
|
|
| 149 |
- assert.ErrorContains(c, err, "") |
|
| 150 |
- } else {
|
|
| 151 |
- assert.NilError(c, err) |
|
| 152 |
- } |
|
| 153 |
- |
|
| 154 |
- dockerCmd(c, "pause", name) |
|
| 155 |
- _, _, err = dockerCmdWithError("update", "--kernel-memory", "200M", name)
|
|
| 156 |
- if !isNewKernel {
|
|
| 157 |
- assert.ErrorContains(c, err, "") |
|
| 158 |
- } else {
|
|
| 159 |
- assert.NilError(c, err) |
|
| 160 |
- } |
|
| 161 |
- dockerCmd(c, "unpause", name) |
|
| 162 |
- |
|
| 163 |
- dockerCmd(c, "stop", name) |
|
| 164 |
- dockerCmd(c, "update", "--kernel-memory", "300M", name) |
|
| 165 |
- dockerCmd(c, "start", name) |
|
| 166 |
- |
|
| 167 |
- assert.Equal(c, inspectField(c, name, "HostConfig.KernelMemory"), "314572800") |
|
| 168 |
- |
|
| 169 |
- file := "/sys/fs/cgroup/memory/memory.kmem.limit_in_bytes" |
|
| 170 |
- out, _ := dockerCmd(c, "exec", name, "cat", file) |
|
| 171 |
- assert.Equal(c, strings.TrimSpace(out), "314572800") |
|
| 172 |
-} |
|
| 173 |
- |
|
| 174 |
-// GetKernelVersion gets the current kernel version. |
|
| 175 |
-func GetKernelVersion() *kernel.VersionInfo {
|
|
| 176 |
- v, _ := kernel.ParseRelease(testEnv.DaemonInfo.KernelVersion) |
|
| 177 |
- return v |
|
| 178 |
-} |
|
| 179 |
- |
|
| 180 |
-// CheckKernelVersion checks if current kernel is newer than (or equal to) |
|
| 181 |
-// the given version. |
|
| 182 |
-func CheckKernelVersion(k, major, minor int) bool {
|
|
| 183 |
- return kernel.CompareKernelVersion(*GetKernelVersion(), kernel.VersionInfo{Kernel: k, Major: major, Minor: minor}) >= 0
|
|
| 184 |
-} |
|
| 185 |
- |
|
| 186 | 125 |
func (s *DockerSuite) TestUpdateSwapMemoryOnly(c *testing.T) {
|
| 187 | 126 |
testRequires(c, DaemonIsLinux) |
| 188 | 127 |
testRequires(c, memoryLimitSupport) |
| ... | ... |
@@ -8,7 +8,6 @@ import ( |
| 8 | 8 |
"os/exec" |
| 9 | 9 |
"strings" |
| 10 | 10 |
|
| 11 |
- "github.com/docker/docker/pkg/parsers/kernel" |
|
| 12 | 11 |
"github.com/docker/docker/pkg/sysinfo" |
| 13 | 12 |
) |
| 14 | 13 |
|
| ... | ... |
@@ -37,21 +36,6 @@ func pidsLimit() bool {
|
| 37 | 37 |
return SysInfo.PidsLimit |
| 38 | 38 |
} |
| 39 | 39 |
|
| 40 |
-func kernelMemorySupport() bool {
|
|
| 41 |
- // TODO remove this once kmem support in RHEL kernels is fixed. See https://github.com/opencontainers/runc/pull/1921 |
|
| 42 |
- daemonV, err := kernel.ParseRelease(testEnv.DaemonInfo.KernelVersion) |
|
| 43 |
- if err != nil {
|
|
| 44 |
- return false |
|
| 45 |
- } |
|
| 46 |
- requiredV := kernel.VersionInfo{Kernel: 3, Major: 10}
|
|
| 47 |
- if kernel.CompareKernelVersion(*daemonV, requiredV) < 1 {
|
|
| 48 |
- // On Kernel 3.10 and under, don't consider kernel memory to be supported, |
|
| 49 |
- // even if the kernel (and thus the daemon) reports it as being supported |
|
| 50 |
- return false |
|
| 51 |
- } |
|
| 52 |
- return testEnv.DaemonInfo.KernelMemory |
|
| 53 |
-} |
|
| 54 |
- |
|
| 55 | 40 |
func memoryLimitSupport() bool {
|
| 56 | 41 |
return testEnv.DaemonInfo.MemoryLimit |
| 57 | 42 |
} |
| ... | ... |
@@ -2,7 +2,6 @@ package container // import "github.com/docker/docker/integration/container" |
| 2 | 2 |
|
| 3 | 3 |
import ( |
| 4 | 4 |
"context" |
| 5 |
- "strconv" |
|
| 6 | 5 |
"strings" |
| 7 | 6 |
"testing" |
| 8 | 7 |
"time" |
| ... | ... |
@@ -17,40 +16,6 @@ import ( |
| 17 | 17 |
"gotest.tools/v3/skip" |
| 18 | 18 |
) |
| 19 | 19 |
|
| 20 |
-func TestKernelTCPMemory(t *testing.T) {
|
|
| 21 |
- skip.If(t, testEnv.DaemonInfo.OSType != "linux") |
|
| 22 |
- skip.If(t, versions.LessThan(testEnv.DaemonAPIVersion(), "1.40"), "skip test from new feature") |
|
| 23 |
- skip.If(t, testEnv.DaemonInfo.CgroupDriver == "none") |
|
| 24 |
- skip.If(t, !testEnv.DaemonInfo.KernelMemoryTCP) |
|
| 25 |
- |
|
| 26 |
- defer setupTest(t)() |
|
| 27 |
- client := testEnv.APIClient() |
|
| 28 |
- ctx := context.Background() |
|
| 29 |
- |
|
| 30 |
- const ( |
|
| 31 |
- kernelMemoryTCP int64 = 200 * 1024 * 1024 |
|
| 32 |
- ) |
|
| 33 |
- |
|
| 34 |
- cID := container.Run(ctx, t, client, func(c *container.TestContainerConfig) {
|
|
| 35 |
- c.HostConfig.Resources = containertypes.Resources{
|
|
| 36 |
- KernelMemoryTCP: kernelMemoryTCP, |
|
| 37 |
- } |
|
| 38 |
- }) |
|
| 39 |
- |
|
| 40 |
- poll.WaitOn(t, container.IsInState(ctx, client, cID, "running"), poll.WithDelay(100*time.Millisecond)) |
|
| 41 |
- |
|
| 42 |
- inspect, err := client.ContainerInspect(ctx, cID) |
|
| 43 |
- assert.NilError(t, err) |
|
| 44 |
- assert.Check(t, is.Equal(kernelMemoryTCP, inspect.HostConfig.KernelMemoryTCP)) |
|
| 45 |
- |
|
| 46 |
- res, err := container.Exec(ctx, client, cID, |
|
| 47 |
- []string{"cat", "/sys/fs/cgroup/memory/memory.kmem.tcp.limit_in_bytes"})
|
|
| 48 |
- assert.NilError(t, err) |
|
| 49 |
- assert.Assert(t, is.Len(res.Stderr(), 0)) |
|
| 50 |
- assert.Equal(t, 0, res.ExitCode) |
|
| 51 |
- assert.Check(t, is.Equal(strconv.FormatInt(kernelMemoryTCP, 10), strings.TrimSpace(res.Stdout()))) |
|
| 52 |
-} |
|
| 53 |
- |
|
| 54 | 20 |
func TestNISDomainname(t *testing.T) {
|
| 55 | 21 |
// Older versions of the daemon would concatenate hostname and domainname, |
| 56 | 22 |
// so hostname "foobar" and domainname "baz.cyphar.com" would produce |