1
0
Fork 0
mirror of https://github.com/moby/moby.git synced 2022-11-09 12:21:53 -05:00

Merge pull request #41168 from thaJeztah/raise_minimum_memory_limit

Set minimum memory limit to 6M, to account for higher startup memory use
This commit is contained in:
Brian Goff 2020-07-09 11:48:34 -07:00 committed by GitHub
commit dd46bbca08
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 10 additions and 12 deletions

View file

@ -68,8 +68,8 @@ const (
linuxMinCPUShares = 2
linuxMaxCPUShares = 262144
platformSupported = true
// It's not kernel limit, we want this 4M limit to supply a reasonable functional container
linuxMinMemory = 4194304
// It's not kernel limit, we want this 6M limit to account for overhead during startup, and to supply a reasonable functional container
linuxMinMemory = 6291456
// constants for remapped root settings
defaultIDSpecifier = "default"
defaultRemappedID = "dockremap"
@ -433,7 +433,7 @@ func verifyPlatformContainerResources(resources *containertypes.Resources, sysIn
// memory subsystem checks and adjustments
if resources.Memory != 0 && resources.Memory < linuxMinMemory {
return warnings, fmt.Errorf("Minimum memory limit allowed is 4MB")
return warnings, fmt.Errorf("Minimum memory limit allowed is 6MB")
}
if resources.Memory > 0 && !sysInfo.MemoryLimit {
warnings = append(warnings, "Your kernel does not support memory limit capabilities or the cgroup is not mounted. Limitation discarded.")

View file

@ -871,7 +871,7 @@ func (s *DockerSuite) TestCreateWithTooLowMemoryLimit(c *testing.T) {
} else {
assert.Assert(c, res.StatusCode != http.StatusOK)
}
assert.Assert(c, strings.Contains(string(b), "Minimum memory limit allowed is 4MB"))
assert.Assert(c, strings.Contains(string(b), "Minimum memory limit allowed is 6MB"))
}
func (s *DockerSuite) TestContainerAPIRename(c *testing.T) {

View file

@ -2826,13 +2826,11 @@ func (s *DockerSuite) TestRunPIDHostWithChildIsKillable(c *testing.T) {
}
func (s *DockerSuite) TestRunWithTooSmallMemoryLimit(c *testing.T) {
// TODO Windows. This may be possible to enable once Windows supports
// memory limits on containers
// TODO Windows. This may be possible to enable once Windows supports memory limits on containers
testRequires(c, DaemonIsLinux)
// this memory limit is 1 byte less than the min, which is 4MB
// https://github.com/docker/docker/blob/v1.5.0/daemon/create.go#L22
out, _, err := dockerCmdWithError("run", "-m", "4194303", "busybox")
if err == nil || !strings.Contains(out, "Minimum memory limit allowed is 4MB") {
// this memory limit is 1 byte less than the min (daemon.linuxMinMemory), which is 6MB (6291456 bytes)
out, _, err := dockerCmdWithError("create", "-m", "6291455", "busybox")
if err == nil || !strings.Contains(out, "Minimum memory limit allowed is 6MB") {
c.Fatalf("expected run to fail when using too low a memory limit: %q", out)
}
}

View file

@ -108,7 +108,7 @@ func (s *DockerSuite) TestUpdateContainerInvalidValue(c *testing.T) {
dockerCmd(c, "run", "-d", "--name", name, "-m", "300M", "busybox", "true")
out, _, err := dockerCmdWithError("update", "-m", "2M", name)
assert.ErrorContains(c, err, "")
expected := "Minimum memory limit allowed is 4MB"
expected := "Minimum memory limit allowed is 6MB"
assert.Assert(c, strings.Contains(out, expected))
}

View file

@ -175,7 +175,7 @@ func (s *DockerSuite) TestDeprecatedStartWithTooLowMemoryLimit(c *testing.T) {
} else {
assert.Equal(c, res.StatusCode, http.StatusBadRequest)
}
assert.Assert(c, is.Contains(string(b), "Minimum memory limit allowed is 4MB"))
assert.Assert(c, is.Contains(string(b), "Minimum memory limit allowed is 6MB"))
}
// #14640