runc-shim: only defer init process exits#9999
Conversation
In order to make sure that we don't publish task exit events for init processes before we do for execs in that container, we added logic to `processExits` in 892dc54 to skip these and let the pending exec's `handleStarted` closure process them. However, the conditional logic in `processExits` added was faulty - we should only defer processing of exit events related to init processes, not other execs. Due to this missing condition, 892dc54 introduced a bug where, if there are many concurrent execs for the same container/init pid, exec exits are skipped and then never published, resulting in hanging clients. This commit adds the missing logic to `processExits`. Signed-off-by: Laura Brehm <laurabrehm@hey.com>
|
I'll add some tests too 😅 sad we didn't catch this here until we did in moby. |
|
Hi folks, thanks for the fix. Please note that the problem being fixed is very serious in that it makes a big mess of Kubernetes exec probes and |
|
Hi @rtheis, thanks for letting us know. Feel free to create an issue – in the meantime, I'll ping people to get this reviewed+merged and open backports. I'll leave tests out for another PR so we can get this merged quicker. |
|
cc @dmcgowan |
| for _, cp := range s.running[e.Pid] { | ||
| if s.pendingExecs[cp.Container] != 0 { | ||
| _, init := cp.Process.(*process.Init) | ||
| if init && s.pendingExecs[cp.Container] != 0 { |
There was a problem hiding this comment.
Yes, I have a patch locally, I'll clean it up and open a PR with the tests.
What this fixes:
In order to make sure that we don't publish task exit events for init processes before we do for execs in that container, we added logic to
processExitsin 892dc54 to skip these and let the pending exec'shandleStartedclosure process them.However, the conditional logic in
processExitsadded was faulty - we should only defer processing of exit events related to init processes, not other execs. Due to this missing condition,892dc54 introduced a bug where, if there are many concurrent execs for the same container/init pid, exec exits are skipped and then never published, resulting in hanging clients.
repro + details
this hangs without this fix, but works before 892dc54.
Instrumenting with some logs, we see this issue:
What I did:
This commit adds the missing logic to
processExits.