Merge pull request #92 from Random-Liu/set-sandbox-resource-limit

Set sandbox container resource limit.
This commit is contained in:
Lantao Liu 2017-06-23 18:06:52 -07:00 committed by GitHub
commit 3a71a974a3
3 changed files with 8 additions and 1 deletions

View File

@ -57,6 +57,10 @@ const (
const ( const (
// defaultSandboxImage is the image used by sandbox container. // defaultSandboxImage is the image used by sandbox container.
defaultSandboxImage = "gcr.io/google_containers/pause:3.0" defaultSandboxImage = "gcr.io/google_containers/pause:3.0"
// defaultSandboxOOMAdj is default omm adj for sandbox container. (kubernetes#47938).
defaultSandboxOOMAdj = -998
// defaultSandboxCPUshares is default cpu shares for sandbox container.
defaultSandboxCPUshares = 2
// defaultShmSize is the default size of the sandbox shm. // defaultShmSize is the default size of the sandbox shm.
defaultShmSize = int64(1024 * 1024 * 64) defaultShmSize = int64(1024 * 1024 * 64)
// relativeRootfsPath is the rootfs path relative to bundle path. // relativeRootfsPath is the rootfs path relative to bundle path.

View File

@ -326,7 +326,8 @@ func (c *criContainerdService) generateSandboxContainerSpec(id string, config *r
// TODO(random-liu): [P2] Set apparmor and seccomp from annotations. // TODO(random-liu): [P2] Set apparmor and seccomp from annotations.
// TODO(random-liu): [P1] Set default sandbox container resource limit. g.SetLinuxResourcesCPUShares(uint64(defaultSandboxCPUshares))
g.SetLinuxResourcesOOMScoreAdj(int(defaultSandboxOOMAdj))
return g.Spec(), nil return g.Spec(), nil
} }

View File

@ -68,6 +68,8 @@ func getRunPodSandboxTestData() (*runtime.PodSandboxConfig, *imagespec.ImageConf
assert.Contains(t, spec.Process.Env, "a=b", "c=d") assert.Contains(t, spec.Process.Env, "a=b", "c=d")
assert.Equal(t, []string{"/pause", "forever"}, spec.Process.Args) assert.Equal(t, []string{"/pause", "forever"}, spec.Process.Args)
assert.Equal(t, "/workspace", spec.Process.Cwd) assert.Equal(t, "/workspace", spec.Process.Cwd)
assert.EqualValues(t, *spec.Linux.Resources.CPU.Shares, defaultSandboxCPUshares)
assert.EqualValues(t, *spec.Linux.Resources.OOMScoreAdj, defaultSandboxOOMAdj)
} }
return config, imageConfig, specCheck return config, imageConfig, specCheck
} }