mirror of
https://github.com/containers/podman.git
synced 2026-10-30 13:50:42 -04:00
Rootless with the cgroupfs manager the pids controller is often not delegated, as on WSL machines. The default path already skips the pids limit there, but an explicit unlimited value (--pids-limit -1 or 0, the PidsLimit=0 every Docker client sends, or pids.limit 0 on the libpod API) still reached crun, which then failed with "controller `pids` is not available". A new cgroup has no pids limit anyway, so drop an unlimited limit in that case. Finite limits are left as they are. Fixes: https://github.com/podman-container-tools/podman/issues/29909 Signed-off-by: Victor Irzak <victor.irzak@zomp.com>
32 lines
894 B
Go
32 lines
894 B
Go
package specgen
|
|
|
|
import (
|
|
spec "github.com/opencontainers/runtime-spec/specs-go"
|
|
"go.podman.io/common/pkg/config"
|
|
"go.podman.io/storage/pkg/unshare"
|
|
)
|
|
|
|
func (s *SpecGenerator) InitResourceLimits(rtc *config.Config) {
|
|
if s.ResourceLimits == nil || s.ResourceLimits.Pids == nil {
|
|
if s.CgroupsMode != "disabled" {
|
|
limit := rtc.PidsLimit()
|
|
if limit != 0 {
|
|
if s.ResourceLimits == nil {
|
|
s.ResourceLimits = &spec.LinuxResources{}
|
|
}
|
|
s.ResourceLimits.Pids = &spec.LinuxPids{
|
|
Limit: &limit,
|
|
}
|
|
}
|
|
}
|
|
return
|
|
}
|
|
|
|
// Rootless with cgroupfs the pids controller is often not delegated, and a
|
|
// new cgroup has no pids limit anyway, so do not ask the runtime to set one.
|
|
if limit := s.ResourceLimits.Pids.Limit; (limit == nil || *limit <= 0) &&
|
|
unshare.IsRootless() && rtc.Engine.CgroupManager != config.SystemdCgroupsManager {
|
|
s.ResourceLimits.Pids = nil
|
|
}
|
|
}
|