mirror of
https://github.com/containers/podman.git
synced 2025-06-06 06:44:53 +08:00
Merge pull request #13413 from giuseppe/pod-no-use-cgroups-if-disabled
libpod: pods do not use cgroups if --cgroups=disabled
This commit is contained in:
@ -1,3 +1,4 @@
|
|||||||
|
//go:build linux
|
||||||
// +build linux
|
// +build linux
|
||||||
|
|
||||||
package libpod
|
package libpod
|
||||||
@ -59,6 +60,7 @@ func (r *Runtime) NewPod(ctx context.Context, p specgen.PodSpecGenerator, option
|
|||||||
pod.valid = true
|
pod.valid = true
|
||||||
|
|
||||||
// Check Cgroup parent sanity, and set it if it was not set
|
// Check Cgroup parent sanity, and set it if it was not set
|
||||||
|
if r.config.Cgroups() != "disabled" {
|
||||||
switch r.config.Engine.CgroupManager {
|
switch r.config.Engine.CgroupManager {
|
||||||
case config.CgroupfsCgroupsManager:
|
case config.CgroupfsCgroupsManager:
|
||||||
canUseCgroup := !rootless.IsRootless() || isRootlessCgroupSet(pod.config.CgroupParent)
|
canUseCgroup := !rootless.IsRootless() || isRootlessCgroupSet(pod.config.CgroupParent)
|
||||||
@ -104,6 +106,7 @@ func (r *Runtime) NewPod(ctx context.Context, p specgen.PodSpecGenerator, option
|
|||||||
default:
|
default:
|
||||||
return nil, errors.Wrapf(define.ErrInvalidArg, "unsupported Cgroup manager: %s - cannot validate cgroup parent", r.config.Engine.CgroupManager)
|
return nil, errors.Wrapf(define.ErrInvalidArg, "unsupported Cgroup manager: %s - cannot validate cgroup parent", r.config.Engine.CgroupManager)
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if pod.config.UsePodCgroup {
|
if pod.config.UsePodCgroup {
|
||||||
logrus.Debugf("Got pod cgroup as %s", pod.state.CgroupPath)
|
logrus.Debugf("Got pod cgroup as %s", pod.state.CgroupPath)
|
||||||
|
@ -562,6 +562,11 @@ var _ = Describe("Verify podman containers.conf usage", func() {
|
|||||||
inspect = podmanTest.Podman([]string{"inspect", "--format", "{{ .HostConfig.Cgroups }}", result.OutputToString()})
|
inspect = podmanTest.Podman([]string{"inspect", "--format", "{{ .HostConfig.Cgroups }}", result.OutputToString()})
|
||||||
inspect.WaitWithDefaultTimeout()
|
inspect.WaitWithDefaultTimeout()
|
||||||
Expect(inspect.OutputToString()).To(Equal("disabled"))
|
Expect(inspect.OutputToString()).To(Equal("disabled"))
|
||||||
|
|
||||||
|
// Check we can also create a pod when cgroups=disabled
|
||||||
|
result = podmanTest.Podman([]string{"pod", "create"})
|
||||||
|
result.WaitWithDefaultTimeout()
|
||||||
|
Expect(result).Should(Exit(0))
|
||||||
})
|
})
|
||||||
|
|
||||||
It("podman containers.conf runtime", func() {
|
It("podman containers.conf runtime", func() {
|
||||||
|
Reference in New Issue
Block a user