-
Notifications
You must be signed in to change notification settings - Fork 3.8k
fix killall when use pidnamespace #3149
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
Conversation
Signed-off-by: Lifubang <lifubang@acmcoder.com>
Signed-off-by: Lifubang <lifubang@acmcoder.com>
Codecov Report
@@ Coverage Diff @@
## master #3149 +/- ##
==========================================
- Coverage 49.25% 45.16% -4.09%
==========================================
Files 100 111 +11
Lines 9415 11962 +2547
==========================================
+ Hits 4637 5403 +766
- Misses 3955 5727 +1772
- Partials 823 832 +9
Continue to review full report at Codecov.
|
fuweid
left a comment
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
and @lifubang could you please to add the testcase for this? Thanks!
I think that original test doesn't cover this case
containerd/container_linux_test.go
Lines 1324 to 1330 in 8722966
| func TestContainerKillInitPidHost(t *testing.T) { | |
| initContainerAndCheckChildrenDieOnKill(t, oci.WithHostNamespace(specs.PIDNamespace)) | |
| } | |
| func TestContainerKillInitKillsChildWhenNotHostPid(t *testing.T) { | |
| initContainerAndCheckChildrenDieOnKill(t) | |
| } |
|
I think it should be cherry-picked into v1.2 release. cc @Random-Liu |
|
Wait. Hmm. I checked the https://github.com/containerd/containerd/pull/2597/files and found it is cgroup share case, not pid namespace. When I remove namespace check in my local And using following script to test So I think we should remove the pid namespace check @lifubang There is the killAll in runc https://github.com/opencontainers/runc/blob/master/libcontainer/init_linux.go#L474 |
|
Thanks! Yes this should be cherry-picked into the relevant release branches |
|
I remember we fixed this in the cri plugin. We didn’t fix this in the shim because that check was just added for shared pod namespace case. See #2558 We may want to fix this in docker instead if we think the issue above is a valid case we would like to support. |
I think this patch may be more easy to fix this situation. Is there any other situations I ignored? |
|
@fuweid I think we can't remove |
|
If my understand is correct, the share same cgroup path is not related to pid namespace. |
|
|
@lifubang thanks for explanation. I think we can close it because it supports for share cgroup case. |
|
but I think we still need think the share cgroup case is what we need here because there might be leakage of process. When the container A joined other container B with pid namespace, the init process in A exits and the child processes are still alive until containerd B is dead. It might be problem here. |
|
Why share cgroup? Why not just put the 2 containers into the same parent
cgroup?
…On Sun, Mar 31, 2019 at 9:02 AM Wei Fu ***@***.***> wrote:
but I think we still need think the share cgroup case because there might
be leakage of process.
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#3149 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AFjVu2s0ujxcGMhmIGdceCSQXO5V0K17ks5vcNwTgaJpZM4cTiB7>
.
|
My English is not very well. @Random-Liu , I think @fuweid 's meaning is only share pid namespace, but don't enter the same cgroup path. I think this is different from share cgroup. Now, they are 3 situations: 1. Share cgroup: two containers have the same cgroup pathThis is the case like the issue #2558 2. Share pid namespace: Container A joined the Container B's pid namespaceThis is the case like the issue moby/moby#38978 3. Use the same parent cgroup: like k8s podI think this situation also don't need I think the case (2) and (3) is used more widely than the case (1) . If I misunderstood some cases, please let me know. Thanks. |
|
And if we can't remove |
|
hi @Random-Liu
Yes. I was thinking the issue #2558 is not common case and |
Oh, this is right. I have test it by And I have test it in runc, it has the same result. @crosbymichael @Random-Liu @fuweid PTAL. |
|
Hi, everyone. I don't know why we need to use the same cgroup path in two containers? Which area it is used for?
|
|
+1 to remove the |
Yes, we should make a decision, remove or use this patch to support everything. |
NVM. I was on my phone during the weekend, so didn't get a chance to read things through. #2558 does require sharing cgroups as you both mentioned :), which I didn't pay attention to. At least for both Moby and CRI use case, we need kill all for shared pid namespace containers. |
|
also cc @georgethebeatle @ostenbom |
|
How about this one? I think if we can't make a decision whether delete shouldKillAllOnExit function or not, we should fix shim service stuck when join other pid namespace with this patch. We can open a new PR after we decide to delete it. |
|
ping @georgethebeatle ~ |
|
ping @georgethebeatle @danail-branekov again~ we need to know the user case here. Thanks |
|
Hi all, So issue #2558 was regarding sandbox container being killed when the sidecar stops. That immediate issue was fixed with PR #2597. However, we overlooked that the PR would result into not killing the sidecar container which seems to be fixed by the current PR. Therefore we think that this PR is fine, maybe you should just add a test to make sure that the sidecar container process gets killed indeed.
In CF Garden there is a use case that the sidecar container may have different limits and therefore should be created in a dedicated cgroup. |
|
Thanks @danail-branekov for the user case. With this PR change, we have several cases here: Case1: share the same path of cgroup, but not same pid-namespaceNo one container will kill all processes when it quits. kernel will kill all processes in the pid-namespace when the init process is dead. No worry about the leaking processes. I think it is the CF Garden user case. Case2: share the same path of cgroup and same pid-namespacecontainerd-shim kills all process in the same cgroup when container quits. If the no-host container quits, all the processes in the same pid-namespace will be killed because the host container init process is killed by runC. I think the result is reasonable. Case3: No share the same path of cgroup but share the same pid-namespacecontainerd-shim kills all processes in the container but it will not impact the host container. Case 4: Share nothingEach container has own pid-namespace and kernel will kill all processes in the pid-namespace when the init process is dead. No worry about the leaking processes. The change is LGTM. |
|
I like the fix! :D And I'm happy that it works for Garden! Regardless of sharing cgroups or not, container has its own pid namespace, init process dies, no kill all is needed. Very straight forward. |
fuweid
left a comment
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
estesp
left a comment
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
Would be good to get @crosbymichael and someone from CF Garden to also approve just to confirm.
|
@estesp The PR looks good from CF Garden point of view, all our tests are fine (@georgethebeatle and myself are Garden representatives) |
|
LGTM |
|
@thaJeztah @crosbymichael Should the same change be made there ? |
@tedyu we are missing that part. could you help to file pr to handle this? thanks! |
For issue moby/moby#38978 :
We should let
KillAllrun when pid namespace path is not empty.Signed-off-by: Lifubang lifubang@acmcoder.com