libct/cgroups: make isSubsystemAvailable v1-specific
This function is only called from cgroupv1 code, so there is no need for it to implement cgroupv2 stuff. Make it v1-specific, and panic if it is called from v2 code (since this is an internal function, the panic would mean incorrect runc code). Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
This commit is contained in:
parent
d5c57dcea6
commit
5785aabc13
|
@ -106,16 +106,7 @@ func findCgroupMountpointAndRootFromReader(reader io.Reader, cgroupPath, subsyst
|
||||||
|
|
||||||
func isSubsystemAvailable(subsystem string) bool {
|
func isSubsystemAvailable(subsystem string) bool {
|
||||||
if IsCgroup2UnifiedMode() {
|
if IsCgroup2UnifiedMode() {
|
||||||
controllers, err := GetAllSubsystems()
|
panic("don't call isSubsystemAvailable from cgroupv2 code")
|
||||||
if err != nil {
|
|
||||||
return false
|
|
||||||
}
|
|
||||||
for _, c := range controllers {
|
|
||||||
if c == subsystem {
|
|
||||||
return true
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return false
|
|
||||||
}
|
}
|
||||||
|
|
||||||
cgroups, err := ParseCgroupFile("/proc/self/cgroup")
|
cgroups, err := ParseCgroupFile("/proc/self/cgroup")
|
||||||
|
|
Loading…
Reference in New Issue