docker kill: fix bug where failed kills didnt fallback to unix kill#41588
Conversation
|
appears to be only the s390x integration tests failing again |
|
hello, we are continuing to see this issue in ECS, any chance we could get some eyes on this fix? |
|
Can an issue describe here manifest if a PID does not exist? We've hit the exact same problem, but there was not a single process in the crontainer even present on the system. I can see guarding |
550ae46 to
198d342
Compare
samuelkarp
left a comment
There was a problem hiding this comment.
I think the code mostly looks good, I'm just not quite clear on one of the changes that was made.
There was a problem hiding this comment.
It looks like this is moving from one magic number to another, but...why 10 seconds here?
Is the goal to move the 10s wait from killProcessDirectly to here? Can you tell me a bit more about why you wanted to make that change?
There was a problem hiding this comment.
yes you are correct about the goal. The reason that was done was just for consistency. If you look across the functions in kill.go there are 3 other calls to container.Wait.
In container_operations_unix.go there were no other calls to container.Wait except here in killProcessDirectly.
It seemed better to keep the waiting functions contained to kill.go just for consistency rather than have a call to container.Wait at two different levels on the call stack.
|
@sparrc @samuelkarp Along with this change, would love to see this get merged. |
1. fixes moby#41587 2. removes potential infinite Wait and goroutine leak at end of kill function fixes moby#41587 Signed-off-by: Cam <[email protected]>
|
Hello, just wanted to ping to see if this PR could be reviewed, thank you! |
cpuguy83
left a comment
There was a problem hiding this comment.
This looks like it makes the existing intent of the code more robust so that at least looks good.
However it seems like if we are getting to the point where we have to call killProcessDirectly, we should instead be calling task.Delete in containerd instead which will (should) ensure that certain sticky situations are cleaned up (like a blocked runc-init) and work more correctly for other runtimes.
@kolyshkin, thoughts?
| return err | ||
| } | ||
| if isZombie { | ||
| return errdefs.System(errors.Errorf("container %s PID %d is zombie and can not be killed. Use the --init option when creating containers to run an init inside the container that forwards signals and reaps processes", stringid.TruncateID(container.ID), pid)) |
There was a problem hiding this comment.
side note: I don't think this error is accurate since the container PID would itself only be a zombie if the shim exited early for whatever reason.
|
@cpuguy83 would it be possible to consider that question in a follow-up PR? I think it's worth breaking that out into two changes. Reason being that this PR mostly retains the same behavior as before while removing the potential for the Changing from a unix |
|
@sparrc IMO, if we are going to introduce a behavior change here (which has been mostly static for awhile), I'd prefer to do it once. |
OK, just to clarify what you mean by If that's the case then I guess we could just delete killProcessDirectly entirely, as it wouldn't be used anywhere anymore. |
|
containerd's task deletion is doing some checks and asks clients to stop the task beforehand. If your container is still running; Deletion wouldn't work. Falling back to containerd-level task deletion may introduce more error cases, like what if containerd is unhealthy. Using Since this is a fallback case, sending SIGKILL seems much robust to me. |
|
@cpuguy83 @kolyshkin thoughts? |
|
@cpuguy83 @kolyshkin thoughts on changing this pid |
| } | ||
|
|
||
| // In case there were some exceptions(e.g., state of zombie and D) | ||
| if system.IsProcessAlive(pid) { |
There was a problem hiding this comment.
This seems redundant/not needed with the zombie check.
|
very keen to get this merged if anyone from docker has time to take a look, happy to walk through the changes if it would help, you can find me in the Gophers and Docker Community slack channels. |
|
@tonistiigi interesting error on s390x; https://ci-next.docker.com/public/blue/rest/organizations/jenkins/pipelines/moby/branches/PR-41588/runs/6/nodes/181/log/?start=0 |
|
@thaJeztah could that be related to this change or do you think it's a flakey failure? |
|
Definitely not related, but hadn't seen that failure before (we were discussing some breaking changes in gRPC recently though, and this felt possibly related) Let me check CI and restart |
| func killProcessDirectly(container *container.Container) error { | ||
| pid := container.GetPID() | ||
| // Ensure that we don't kill ourselves | ||
| if pid == 0 { |
There was a problem hiding this comment.
Not for this PR, but we should consider making this
| if pid == 0 { | |
| if pid <= 0 { |
I recall a situation where -1 was returned (by containerd?) because it was initialised with -1, and killing -1 does "fun things" 😅
function
and into kill.go for consistency
fixes #41587
Signed-off-by: Cam [email protected]
before change
docker kill would just return error if the first sigkill function failed:
after change
docker falls back to unix kill and container exits:
docker logs:
- Description for the changelog
fix bug where docker kill would not properly fallback to unix sigkill
- A picture of a cute animal (not mandatory but encouraged)