Skip to content

Commit e06c8b3

Browse files
Warn user when host is using cgroup v1
1 parent ff8165d commit e06c8b3

File tree

3 files changed

+27
-0
lines changed

3 files changed

+27
-0
lines changed

pkg/drivers/kic/oci/cgroups_linux.go

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,3 +80,21 @@ func hasMemorySwapCgroup() bool {
8080
}
8181
return true
8282
}
83+
84+
// IsCgroupV2 returns true if the host is using cgroup v2
85+
func IsCgroupV2() bool {
86+
_, err := os.Stat("/sys/fs/cgroup/cgroup.controllers")
87+
return err == nil
88+
}
89+
90+
// WarnIfCgroupV1 prints a warning if host is using cgroup v1
91+
func WarnIfCgroupV1() {
92+
if !IsCgroupV2() {
93+
klog.Warning(
94+
"Host system is using cgroup v1. " +
95+
"Minikube will not enable cgroup v2. " +
96+
"Some features may not work as expected.",
97+
)
98+
}
99+
}
100+

pkg/drivers/kic/oci/cgroups_other.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,3 +25,8 @@ func HasMemoryCgroup() bool {
2525
func hasMemorySwapCgroup() bool {
2626
return true
2727
}
28+
29+
// WarnIfCgroupV1 is a no-op on non-Linux systems
30+
func WarnIfCgroupV1() {
31+
// no-op
32+
}

pkg/drivers/kic/oci/oci.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -159,6 +159,10 @@ func CreateContainerNode(p CreateParams) error { //nolint to suppress cyclomatic
159159
return errors.Wrap(err, "daemon info")
160160
}
161161
}
162+
if runtime.GOOS == "linux" {
163+
WarnIfCgroupV1()
164+
}
165+
162166

163167
runArgs := []string{
164168
"-d", // run the container detached

0 commit comments

Comments
 (0)