mirror of https://github.com/containers/podman.git
libpod: pods do not use cgroups if --cgroups=disabled
do not attempt to use cgroups with pods if the cgroups are disabled. A similar check is already in place for containers. Closes: https://github.com/containers/podman/issues/13411 Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
This commit is contained in:
parent
7877b02aac
commit
a901c919ab
|
@ -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() {
|
||||||
|
|
Loading…
Reference in New Issue