mirror of
https://github.com/netbirdio/gvisor.git
synced 2026-05-22 17:12:49 -07:00
Propagate PID limit from OCI to sandbox cgroup
Closes #2489 PiperOrigin-RevId: 308362434
This commit is contained in:
committed by
gVisor bot
parent
10725475c3
commit
4af39dd1c5
+12
-2
@@ -45,13 +45,13 @@ var controllers = map[string]controller{
|
||||
"memory": &memory{},
|
||||
"net_cls": &networkClass{},
|
||||
"net_prio": &networkPrio{},
|
||||
"pids": &pids{},
|
||||
|
||||
// These controllers either don't have anything in the OCI spec or is
|
||||
// irrevalant for a sandbox, e.g. pids.
|
||||
// irrelevant for a sandbox.
|
||||
"devices": &noop{},
|
||||
"freezer": &noop{},
|
||||
"perf_event": &noop{},
|
||||
"pids": &noop{},
|
||||
"systemd": &noop{},
|
||||
}
|
||||
|
||||
@@ -525,3 +525,13 @@ func (*networkPrio) set(spec *specs.LinuxResources, path string) error {
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
type pids struct{}
|
||||
|
||||
func (*pids) set(spec *specs.LinuxResources, path string) error {
|
||||
if spec.Pids == nil {
|
||||
return nil
|
||||
}
|
||||
val := strconv.FormatInt(spec.Pids.Limit, 10)
|
||||
return setValue(path, "pids.max", val)
|
||||
}
|
||||
|
||||
@@ -199,6 +199,12 @@ func TestCgroup(t *testing.T) {
|
||||
want: "750",
|
||||
skipIfNotFound: true, // blkio groups may not be available.
|
||||
},
|
||||
{
|
||||
arg: "--pids-limit=1000",
|
||||
ctrl: "pids",
|
||||
file: "pids.max",
|
||||
want: "1000",
|
||||
},
|
||||
}
|
||||
|
||||
args := make([]string, 0, len(attrs))
|
||||
|
||||
Reference in New Issue
Block a user