Skip to content
Closed
Show file tree
Hide file tree
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
3 changes: 3 additions & 0 deletions libcontainer/cgroups/fs/apply_raw.go
Original file line number Diff line number Diff line change
Expand Up @@ -270,6 +270,9 @@ func (raw *cgroupData) path(subsystem string) (string, error) {
}

cgPath := filepath.Join(raw.parent, raw.name)
if raw.config.CgroupsPath != "" {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am not sure we should just completely ignore parent and name if cgroupsPath is provided. Docker uses parent and name, and do we want to break compatibility? Also, cgroupsPath must always be relative to the cgroups mount on the system. I'm not sure if the same restriction applies to parent and name.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It won't break compatibility, Docker can still use parent and name, but before it call runc apis, Docker needs to combine parent and name to CgroupPath. And yes, I think parent and name also have the restriction to be relative to cgroups mount point.

cgPath = raw.config.CgroupsPath
}
// If the cgroup name/path is absolute do not look relative to the cgroup of the init process.
if filepath.IsAbs(cgPath) {
// Sometimes subsystems can be mounted togethger as 'cpu,cpuacct'.
Expand Down
3 changes: 3 additions & 0 deletions libcontainer/configs/cgroup_unix.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@ type Cgroup struct {
// name of parent cgroup or slice
Parent string `json:"parent"`

// CgroupsPath specifies the path to cgroups that are created and/or joined by the container.
CgroupsPath string `json:"cgroupsPath"`
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If we want to avoid adding an additional field, we could overload Name and treat it as cgroupsPath if it is absolute. That way we don't need to have Parent, Name as well as CgroupsPath. WDYT?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, that's what I planed, when we merge this, we can start removing Parent and Name.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hmm i think we can just start removing them here ? I think it's also clearer when we integrate this with docker too since there will be complication errors :p


// If this is true allow access to any kind of device within the container. If false, allow access only to devices explicitly listed in the allowed_devices list.
AllowAllDevices bool `json:"allow_all_devices"`

Expand Down
1 change: 1 addition & 0 deletions spec.go
Original file line number Diff line number Diff line change
Expand Up @@ -441,6 +441,7 @@ func createCgroupConfig(name string, spec *specs.LinuxRuntimeSpec, devices []*co
c := &configs.Cgroup{
Name: name,
Parent: myCgroupPath,
CgroupsPath: spec.Linux.CgroupsPath,
AllowedDevices: append(devices, allowedDevices...),
}
r := spec.Linux.Resources
Expand Down