mirror of
https://github.com/containers/podman.git
synced 2025-07-04 01:48:28 +08:00
Merge pull request #13879 from umohnani8/v3.2.3-rhel
[v3.2.3-rhel] backport libpod: refine check for empty pod cgroup
This commit is contained in:
@ -2311,6 +2311,24 @@ func isRootlessCgroupSet(cgroup string) bool {
|
||||
return cgroup != CgroupfsDefaultCgroupParent && filepath.Dir(cgroup) != CgroupfsDefaultCgroupParent
|
||||
}
|
||||
|
||||
func (c *Container) expectPodCgroup() (bool, error) {
|
||||
unified, err := cgroups.IsCgroup2UnifiedMode()
|
||||
if err != nil {
|
||||
return false, err
|
||||
}
|
||||
cgroupManager := c.CgroupManager()
|
||||
switch {
|
||||
case c.config.NoCgroups:
|
||||
return false, nil
|
||||
case cgroupManager == config.SystemdCgroupsManager:
|
||||
return !rootless.IsRootless() || unified, nil
|
||||
case cgroupManager == config.CgroupfsCgroupsManager:
|
||||
return !rootless.IsRootless(), nil
|
||||
default:
|
||||
return false, errors.Wrapf(define.ErrInvalidArg, "invalid cgroup mode %s requested for pods", cgroupManager)
|
||||
}
|
||||
}
|
||||
|
||||
// Get cgroup path in a format suitable for the OCI spec
|
||||
func (c *Container) getOCICgroupPath() (string, error) {
|
||||
unified, err := cgroups.IsCgroup2UnifiedMode()
|
||||
|
@ -292,7 +292,11 @@ func (r *Runtime) setupContainer(ctx context.Context, ctr *Container) (_ *Contai
|
||||
if err != nil {
|
||||
return nil, errors.Wrapf(err, "error retrieving pod %s cgroup", pod.ID())
|
||||
}
|
||||
if podCgroup == "" {
|
||||
expectPodCgroup, err := ctr.expectPodCgroup()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if expectPodCgroup && podCgroup == "" {
|
||||
return nil, errors.Wrapf(define.ErrInternal, "pod %s cgroup is not set", pod.ID())
|
||||
}
|
||||
canUseCgroup := !rootless.IsRootless() || isRootlessCgroupSet(podCgroup)
|
||||
|
Reference in New Issue
Block a user