-
Notifications
You must be signed in to change notification settings - Fork 2.3k
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
Support running integration tests on cgroupv2 hosts #3143
Conversation
7b1cf42
to
bdc0932
Compare
@tstapler ptal |
integration/tests/api/docker_test.go
Outdated
@@ -211,7 +212,15 @@ func TestDockerContainerSpec(t *testing.T) { | |||
assert := assert.New(t) | |||
|
|||
assert.True(containerInfo.Spec.HasCpu, "CPU should be isolated") | |||
assert.Equal(cpuShares, containerInfo.Spec.Cpu.Limit, "Container should have %d shares, has %d", cpuShares, containerInfo.Spec.Cpu.Limit) | |||
if cgroups.IsCgroup2UnifiedMode() { | |||
// see https://github.com/google/cadvisor/blob/24e7a9883d12f944fd4403861707f4bafcaf4f3d/container/common/helpers.go#L249-L260 |
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.
Could you add more context to this comment. Is it pointing out how shares are calculated?
If so, perhaps replace // see
with // see how cpu shares are calculated
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.
updated comment to be a bit more clear, ptal :)
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.
# otherwise writing subtree_control fails with EBUSY. | ||
# An error during moving non-existent process (i.e., "cat") is ignored. | ||
mkdir -p /sys/fs/cgroup/init | ||
xargs -rn1 < /sys/fs/cgroup/cgroup.procs > /sys/fs/cgroup/init/cgroup.procs || : |
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.
What does this xargs block do?
I can see that -r
is do not run the command if there is no stdin, and -n1 is max args 1?
but I don't see a command that its executing.
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 copied this over from https://github.com/moby/moby/blob/master/hack/dind :)
So the idea here, is that for docker in docker for cgroupv2 we need to be move all the processes in a child cgroup or else we will hit the runc/cgroupv2 limitation mentioned here - containerd/containerd#6659 (comment)
The goal here is to first create a new cgroup (mkdir -p /sys/fs/cgroup/init
). Then we want to copy all of pids one by one from /sys/fs/cgroup/cgroup.procs
to the new child cgroup /sys/fs/cgroup/init/cgroup.procs
(the xargs -rn1
ensures the list of pids is split one by one).
There is no command being passed to xargs, so as a result it will simply echo each pid entry (see https://unix.stackexchange.com/questions/110134/what-does-xargs-do-if-its-used-without-any-parameter)
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.
Neat, so xargs allows you to copy the file but throw an error if the source doesn't have any lines in it.
The new comment is helpful thanks!
On cgroupv2, we need to use the helper function to locate the controller. Signed-off-by: David Porter <porterdavid@google.com>
Fix a few of the integration tests to be cgroupv2 compatible. Signed-off-by: David Porter <porterdavid@google.com>
Updated based on your feedback, ptal again |
@bobbypage: The following test failed, say
Full PR test history. Your PR dashboard. Please help us cut down on flakes by linking to an open issue when you hit one in your PR. Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. I understand the commands that are listed here. |
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.
Thanks for adding the extra context
lgtm
Adds a few fixes to the integration tests to support running on cgroupv2. Now running
make docker-test-integration
on a cgroupv2 host should work fine.