-
Notifications
You must be signed in to change notification settings - Fork 236
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
Fix systemd full path #221
Conversation
101617f
to
1cb87d9
Compare
Seems like we have a new intermittent issue with either tests hanging or something with CI cleanup on the vagrant-executed v2 suite. It's happening on a few other PRs as well. |
// getSystemdFullPath returns the full systemd path when creating a systemd slice group. | ||
// the reason this is necessary is because the "-" character has a special meaning in | ||
// systemd slice. For example, when creating a slice called "my-group-112233.slice", | ||
// systemd will create a hierarchy like this: | ||
// /sys/fs/cgroup/my.slice/my-group.slice/my-group-112233.slice | ||
func getSystemdFullPath(slice, group string) string { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do you know the corresponding code in systemd? Is it documented?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I will try to find documentation from systemd itself and look thru the code. What I have so far is just observation that this is what the resulting cgroup path created by NewSystemd is, and this doc from redhat, which states:
Service, scope, and slice units directly map to objects in the cgroup tree. When these units are activated, they map directly to cgroup paths built from the unit names. For example, the ex.service residing in the test-waldo.slice is mapped to the cgroup test.slice/test-waldo.slice/ex.service/.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Might be https://github.com/systemd/systemd/blob/166e8e36eba661ba5d30974b71241ab0e3f49f37/src/basic/unit-name.c#L622? But well, reading systemd is harder than I thought...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
FWIW, the docker run
command also appears to understand this "-" notation when specified by the --cgroup-parent
flag, though I suppose similar to here it's because the parsing is passed off to systemd itself.
% docker run -d --rm --name test2 --cgroup-parent "my-foo-group.slice" debian:stable-slim sleep 1000
ae96786b7f24e7d469be36c44cdb48bf913b33dc10ed3095c6249b380b1a5699
% find /sys/fs/cgroup | grep my-foo-group | grep ae96786b7f24e7
/sys/fs/cgroup/my.slice/my-foo.slice/my-foo-group.slice/docker-ae96786b7f24e7d469be36c44cdb48bf913b33dc10ed3095c6249b380b1a5699.scope
/sys/fs/cgroup/my.slice/my-foo.slice/my-foo-group.slice/docker-ae96786b7f24e7d469be36c44cdb48bf913b33dc10ed3095c6249b380b1a5699.scope/cgroup.events
/sys/fs/cgroup/my.slice/my-foo.slice/my-foo-group.slice/docker-ae96786b7f24e7d469be36c44cdb48bf913b33dc10ed3095c6249b380b1a5699.scope/memory.events
...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the systemd.slice
man page does have some (albeit sparse) information about this: https://www.freedesktop.org/software/systemd/man/systemd.slice.html
Can you try rebasing this patch on current |
Signed-off-by: Cameron Sparr <sparrc@users.noreply.github.com>
1cb87d9
to
aa8003c
Compare
done, looks like it worked 👍 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
This PR fixes systemd managers to consider the special "-" character when creating a cgroup slice with the systemd cgroup driver.
Before this change, a simple program like below would fail because the manager was not correctly setting up the Manager.path variable.
Before this change, this program would fail with the following error message:
The issue here is that m.Controllers() is looking in the wrong path. This slice does actually exist, but at a different path:
After this change, NewSystemd (and LoadSystemd) will correctly set the path variable and the m.Controllers() function works correctly: