Skip to content

Commit

Permalink
cgroups2: Fix mountpoint detection (#50)
Browse files Browse the repository at this point in the history
In #44, we accidentally turned v2 mountpoint detection
from "are any of the mountpoints v2 to "is the last mountpoint v2".
This fixes that condition and updates the test case to catch that in
the future.

Resolves #49
  • Loading branch information
mway authored Apr 6, 2022
1 parent 2e85815 commit 721b013
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
2 changes: 1 addition & 1 deletion internal/cgroups/cgroups2.go
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ func isCGroupV2(procPathMountInfo string) (bool, error) {
var (
isV2 bool
newMountPoint = func(mp *MountPoint) error {
isV2 = mp.FSType == _cgroupv2FSType && mp.MountPoint == _cgroupv2MountPoint
isV2 = isV2 || (mp.FSType == _cgroupv2FSType && mp.MountPoint == _cgroupv2MountPoint)
return nil
}
)
Expand Down
3 changes: 2 additions & 1 deletion internal/cgroups/testdata/proc/v2/mountinfo-v2
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
34 33 0:29 / /sys/fs/cgroup rw,nosuid,nodev,noexec,relatime shared:10 - cgroup2 cgroup rw,nsdelegate
34 33 0:29 / /sys/fs/cgroup rw,nosuid,nodev,noexec,relatime shared:10 - cgroup2 cgroup rw,nsdelegate
34 33 0:29 / /sys/fs/foo rw,nosuid,nodev,noexec,relatime shared:10 - foo cgroup rw,nsdelegate

0 comments on commit 721b013

Please sign in to comment.