1
0
mirror of https://github.com/opencontainers/runc.git synced 2025-08-08 12:42:06 +03:00

libcontainer/cgroup: obsolete Get*Cgroup for v2

These functions should not be called from any code handling
the cgroup2 unified hierarchy.

Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
This commit is contained in:
Kir Kolyshkin
2020-03-26 14:00:15 -07:00
parent a949e4f22f
commit b45db5d3b2

View File

@@ -4,6 +4,7 @@ package cgroups
import ( import (
"bufio" "bufio"
"errors"
"fmt" "fmt"
"io" "io"
"io/ioutil" "io/ioutil"
@@ -28,6 +29,8 @@ const (
var ( var (
isUnifiedOnce sync.Once isUnifiedOnce sync.Once
isUnified bool isUnified bool
errUnified = errors.New("not implemented for cgroup v2 unified hierarchy")
) )
// HugePageSizeUnitList is a list of the units used by the linux kernel when // HugePageSizeUnitList is a list of the units used by the linux kernel when
@@ -307,6 +310,9 @@ func GetAllSubsystems() ([]string, error) {
// GetOwnCgroup returns the relative path to the cgroup docker is running in. // GetOwnCgroup returns the relative path to the cgroup docker is running in.
func GetOwnCgroup(subsystem string) (string, error) { func GetOwnCgroup(subsystem string) (string, error) {
if IsCgroup2UnifiedMode() {
return "", errUnified
}
cgroups, err := ParseCgroupFile("/proc/self/cgroup") cgroups, err := ParseCgroupFile("/proc/self/cgroup")
if err != nil { if err != nil {
return "", err return "", err
@@ -325,6 +331,9 @@ func GetOwnCgroupPath(subsystem string) (string, error) {
} }
func GetInitCgroup(subsystem string) (string, error) { func GetInitCgroup(subsystem string) (string, error) {
if IsCgroup2UnifiedMode() {
return "", errUnified
}
cgroups, err := ParseCgroupFile("/proc/1/cgroup") cgroups, err := ParseCgroupFile("/proc/1/cgroup")
if err != nil { if err != nil {
return "", err return "", err