Merge pull request #970 from AkihiroSuda/rootless
support DisableCgroup, DisableApparmor, RestrictOOMScoreAdj
This commit is contained in:
@@ -375,10 +375,14 @@ func (c *criService) generateSandboxContainerSpec(id string, config *runtime.Pod
|
||||
// TODO(random-liu): [P2] Consider whether to add labels and annotations to the container.
|
||||
|
||||
// Set cgroups parent.
|
||||
if config.GetLinux().GetCgroupParent() != "" {
|
||||
cgroupsPath := getCgroupsPath(config.GetLinux().GetCgroupParent(), id,
|
||||
c.config.SystemdCgroup)
|
||||
g.SetLinuxCgroupsPath(cgroupsPath)
|
||||
if c.config.DisableCgroup {
|
||||
g.SetLinuxCgroupsPath("")
|
||||
} else {
|
||||
if config.GetLinux().GetCgroupParent() != "" {
|
||||
cgroupsPath := getCgroupsPath(config.GetLinux().GetCgroupParent(), id,
|
||||
c.config.SystemdCgroup)
|
||||
g.SetLinuxCgroupsPath(cgroupsPath)
|
||||
}
|
||||
}
|
||||
// When cgroup parent is not set, containerd-shim will create container in a child cgroup
|
||||
// of the cgroup itself is in.
|
||||
@@ -434,8 +438,17 @@ func (c *criService) generateSandboxContainerSpec(id string, config *runtime.Pod
|
||||
|
||||
// Note: LinuxSandboxSecurityContext does not currently provide an apparmor profile
|
||||
|
||||
g.SetLinuxResourcesCPUShares(uint64(defaultSandboxCPUshares))
|
||||
g.SetProcessOOMScoreAdj(int(defaultSandboxOOMAdj))
|
||||
if !c.config.DisableCgroup {
|
||||
g.SetLinuxResourcesCPUShares(uint64(defaultSandboxCPUshares))
|
||||
}
|
||||
adj := int(defaultSandboxOOMAdj)
|
||||
if c.config.RestrictOOMScoreAdj {
|
||||
adj, err = restrictOOMScoreAdj(adj)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
}
|
||||
g.SetProcessOOMScoreAdj(adj)
|
||||
|
||||
g.AddAnnotation(annotations.ContainerType, annotations.ContainerTypeSandbox)
|
||||
g.AddAnnotation(annotations.SandboxID, id)
|
||||
|
||||
Reference in New Issue
Block a user