Skip to content

Commit aeb6730

Browse files
committed
common/pkg/cgroups: remove IsCgroup2UnifiedMode
common/pkg/cgroupv2.Enabled provides the same functionality that podman and buildah could call in main to check for Cgroups v2. Keep IsCgroup2UnifiedMode in cgroups_unsupported.go for buildah cross compiles. Signed-off-by: Lokesh Mandvekar <[email protected]>
1 parent 49ab99d commit aeb6730

File tree

2 files changed

+1
-19
lines changed

2 files changed

+1
-19
lines changed

common/pkg/cgroups/cgroups_linux.go

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ import (
1313
"path/filepath"
1414
"strconv"
1515
"strings"
16-
"sync"
1716
"syscall"
1817
"time"
1918

@@ -31,10 +30,6 @@ var (
3130
// ErrCgroupDeleted means the cgroup was deleted.
3231
ErrCgroupDeleted = errors.New("cgroup deleted")
3332
ErrStatCgroup = errors.New("no cgroup available for gathering user statistics")
34-
35-
isUnifiedOnce sync.Once
36-
isUnified bool
37-
isUnifiedErr error
3833
)
3934

4035
// CgroupControl controls a cgroup hierarchy.
@@ -605,19 +600,6 @@ func SystemCPUUsage() (uint64, error) {
605600
return total, nil
606601
}
607602

608-
// IsCgroup2UnifiedMode returns whether we are running in cgroup 2 cgroup2 mode.
609-
func IsCgroup2UnifiedMode() (bool, error) {
610-
isUnifiedOnce.Do(func() {
611-
var st syscall.Statfs_t
612-
if err := syscall.Statfs("/sys/fs/cgroup", &st); err != nil {
613-
isUnified, isUnifiedErr = false, err
614-
} else {
615-
isUnified, isUnifiedErr = st.Type == unix.CGROUP2_SUPER_MAGIC, nil
616-
}
617-
})
618-
return isUnified, isUnifiedErr
619-
}
620-
621603
// UserConnection returns an user connection to D-BUS.
622604
func UserConnection(uid int) (*systemdDbus.Conn, error) {
623605
return systemdDbus.NewConnection(func() (*dbus.Conn, error) {

common/pkg/cgroups/cgroups_unsupported.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
package cgroups
44

5-
// IsCgroup2UnifiedMode returns whether we are running in cgroup 2 cgroup2 mode.
5+
// IsCgroup2UnifiedMode returns whether we are running in cgroup 2 unified mode.
66
func IsCgroup2UnifiedMode() (bool, error) {
77
return false, nil
88
}

0 commit comments

Comments
 (0)