Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Fix cgroups detection #134

Merged
merged 2 commits into from
Mar 16, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions cgroup/cgroup.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ const (
type CGroupVersion int

const (
CGroupUnknown CGroupVersion = 0
CGroupUnknown CGroupVersion = iota
CGroupV1
CGroupV2
)
Expand Down Expand Up @@ -71,7 +71,7 @@ func (d cgroup) AddDevicesAllowed(containerID string, permission string) (bool,
logging.Info.Printf("Successfully called runc for '%s', output %s", containerID, stdoutStderr)
}

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

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

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