Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

[WIP] cgroupv2: fix systemd driver not putting pid into cgroup #2311

Closed
Closed
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/systemd/unified_hierarchy.go
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,9 @@ func (m *UnifiedManager) Apply(pid int) error {
if err := createCgroupsv2Path(path); err != nil {
return err
}
if err := cgroups.WriteCgroupProc(path, pid); err != nil {
Copy link
Member

Choose a reason for hiding this comment

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

isn't it done automatically by systemd?

I see we are specifying the PID here: https://github.com/opencontainers/runc/blob/master/libcontainer/cgroups/systemd/unified_hierarchy.go#L61-L63

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I see that systemd v1 driver (aka LegacyManager) is doing it explicitly:

  • Apply -> joinCgroups -> join for all controllers except cpuset
  • ... -> cpuset.ApplyDir for cpuset

if err := cgroups.WriteCgroupProc(path, pid); err != nil {

Copy link
Member

Choose a reason for hiding this comment

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

I guess it is done because some controllers are not supported by systemd (like cpuset). On cgroup v2 it is enough to join the cgroup once.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@giuseppe you're right, adding PIDs property should be enough, and yet it is not working. Investigating.

Copy link
Member

Choose a reason for hiding this comment

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

I'd investigate if dbusConnection.StartTransientUnit waits correctly that the systemd unit is created. Does it eventually join the correct cgroup if you add a sleep here?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

return err
}
m.Paths = map[string]string{
"pids": path,
"memory": path,
Expand Down