mirror of
https://github.com/netbirdio/gvisor.git
synced 2026-05-22 17:12:49 -07:00
Make more cgroup controllers optional
Mark all noop cgroups as optional, after all there is no harm in skipping them. Make pids cgroup optional because they are not present on Synology NAS. Closes #6856 PiperOrigin-RevId: 409197613
This commit is contained in:
committed by
gVisor bot
parent
1d536f8139
commit
83eb263b45
+14
-10
@@ -57,7 +57,7 @@ var controllers = map[string]controller{
|
||||
"devices": &noop{},
|
||||
"freezer": &noop{},
|
||||
"perf_event": &noop{},
|
||||
"rdma": &noop{isOptional: true},
|
||||
"rdma": &noop{},
|
||||
"systemd": &noop{},
|
||||
}
|
||||
|
||||
@@ -599,12 +599,10 @@ type controller interface {
|
||||
skip(*specs.LinuxResources) error
|
||||
}
|
||||
|
||||
type noop struct {
|
||||
isOptional bool
|
||||
}
|
||||
type noop struct{}
|
||||
|
||||
func (n *noop) optional() bool {
|
||||
return n.isOptional
|
||||
return true
|
||||
}
|
||||
|
||||
func (*noop) set(*specs.LinuxResources, string) error {
|
||||
@@ -612,9 +610,6 @@ func (*noop) set(*specs.LinuxResources, string) error {
|
||||
}
|
||||
|
||||
func (n *noop) skip(*specs.LinuxResources) error {
|
||||
if !n.isOptional {
|
||||
panic("cgroup controller is not optional")
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -808,8 +803,17 @@ func (*networkPrio) skip(spec *specs.LinuxResources) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
type pids struct {
|
||||
mandatory
|
||||
type pids struct{}
|
||||
|
||||
func (*pids) optional() bool {
|
||||
return true
|
||||
}
|
||||
|
||||
func (*pids) skip(spec *specs.LinuxResources) error {
|
||||
if spec != nil && spec.Pids != nil && spec.Pids.Limit > 0 {
|
||||
return fmt.Errorf("Pids.Limit set but pids cgroup controller not found")
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (*pids) set(spec *specs.LinuxResources, path string) error {
|
||||
|
||||
@@ -863,6 +863,12 @@ func TestOptional(t *testing.T) {
|
||||
spec *specs.LinuxResources
|
||||
err string
|
||||
}{
|
||||
{
|
||||
name: "pids",
|
||||
ctrlr: &pids{},
|
||||
spec: &specs.LinuxResources{Pids: &specs.LinuxPids{Limit: 1}},
|
||||
err: "Pids.Limit set but pids cgroup controller not found",
|
||||
},
|
||||
{
|
||||
name: "net-cls",
|
||||
ctrlr: &networkClass{},
|
||||
|
||||
Reference in New Issue
Block a user