mirror of
https://github.com/podman-container-tools/podman.git
synced 2026-10-16 10:57:49 +00:00
Docker documents HostConfig.PidsLimit 0 as unlimited, but runc sets pids.max=1 for OCI pids.limit 0. Normalize 0 to -1 when building the OCI spec so native CLI, compat API, and kube play behave consistently. Fixes: https://github.com/podman-container-tools/podman/issues/29826 Signed-off-by: Jan Rodák <hony.com@seznam.cz>
14 lines
436 B
Go
14 lines
436 B
Go
package specgenutil
|
|
|
|
// PidsLimitForOCI returns the value to store in the OCI runtime spec
|
|
// linux.resources.pids.limit field.
|
|
//
|
|
// Docker documents HostConfig.PidsLimit 0 as unlimited. runc maps OCI limit 0 to
|
|
// cgroup pids.max=1, while -1 means unlimited. crun treats 0 as unlimited.
|
|
// Normalize 0 to -1 so all runtimes get unlimited pids.
|
|
func PidsLimitForOCI(limit int64) int64 {
|
|
if limit == 0 {
|
|
return -1
|
|
}
|
|
return limit
|
|
}
|