Merge pull request #92 from Random-Liu/set-sandbox-resource-limit
Set sandbox container resource limit.
This commit is contained in:
commit
3a71a974a3
@ -57,6 +57,10 @@ const (
|
||||
const (
|
||||
// defaultSandboxImage is the image used by sandbox container.
|
||||
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 = int64(1024 * 1024 * 64)
|
||||
// relativeRootfsPath is the rootfs path relative to bundle path.
|
||||
|
@ -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): [P1] Set default sandbox container resource limit.
|
||||
g.SetLinuxResourcesCPUShares(uint64(defaultSandboxCPUshares))
|
||||
g.SetLinuxResourcesOOMScoreAdj(int(defaultSandboxOOMAdj))
|
||||
|
||||
return g.Spec(), nil
|
||||
}
|
||||
|
@ -68,6 +68,8 @@ func getRunPodSandboxTestData() (*runtime.PodSandboxConfig, *imagespec.ImageConf
|
||||
assert.Contains(t, spec.Process.Env, "a=b", "c=d")
|
||||
assert.Equal(t, []string{"/pause", "forever"}, spec.Process.Args)
|
||||
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
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user