Skip to content

Commit 957be69

Browse files
authored
Fix cgroups detection (#134)
* Use a proper enum to fix CGroupsV2 detection * Fix argument order in info messages
1 parent a703490 commit 957be69

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

cgroup/cgroup.go

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ const (
2424
type CGroupVersion int
2525

2626
const (
27-
CGroupUnknown CGroupVersion = 0
27+
CGroupUnknown CGroupVersion = iota
2828
CGroupV1
2929
CGroupV2
3030
)
@@ -71,7 +71,7 @@ func (d cgroup) AddDevicesAllowed(containerID string, permission string) (bool,
7171
logging.Info.Printf("Successfully called runc for '%s', output %s", containerID, stdoutStderr)
7272
}
7373

74-
logging.Info.Printf("Permission '%s', granted for Container '%s' via runc", containerID, permission)
74+
logging.Info.Printf("Permission '%s', granted for Container '%s' via runc", permission, containerID)
7575
return true, nil
7676
} else {
7777
// Make sure path is relative to cgroupFSDockerDevices
@@ -98,7 +98,7 @@ func (d cgroup) AddDevicesAllowed(containerID string, permission string) (bool,
9898
return false, dbus.MakeFailedError(fmt.Errorf("Can't write CGroup permission '%s': %s", permission, err))
9999
}
100100

101-
logging.Info.Printf("Permission '%s', granted for Container '%s' via CGroup devices.allow", containerID, permission)
101+
logging.Info.Printf("Permission '%s', granted for Container '%s' via CGroup devices.allow", permission, containerID)
102102
return true, nil
103103
}
104104
}
@@ -112,8 +112,10 @@ func InitializeDBus(conn *dbus.Conn) {
112112
// Check for CGroups v2
113113
if _, err := os.Stat("/sys/fs/cgroup/cgroup.controllers"); err == nil {
114114
d.cgroupVersion = CGroupV2
115+
logging.Info.Printf("Detected CGroups Version 2")
115116
} else {
116117
d.cgroupVersion = CGroupV1
118+
logging.Info.Printf("Detected CGroups Version 1")
117119
}
118120

119121
err := conn.Export(d, objectPath, ifaceName)

0 commit comments

Comments
 (0)