containerd/cmd
Laura Brehm 892dc54bd2
runc-shim: process exec exits before init
For a given container, as long as the init process is the init process
of that PID namespace, we always receive the exits for execs before we
receive them for the init process.

It's important that we uphold this invariant for the outside world by
always emitting a TastExit event for a container's exec before we emit
one for the init process because this is the expected behavior from
callers, and changing this creates issues - such as Docker, which will
delete the container after receiving a TaskExit for the init process,
and then not be able to handle the exec's exit after having deleted
the container (see: https://github.com/containerd/containerd/issues/9719).

Since 5cd6210ad0, if an exec is starting
at the same time that an init exits, if the exec is an "early exit"
i.e. we haven't emitted a TaskStart for it/put it in `s.running` by the
time we receive it's exit, we notify concurrent calls to `s.Start()` of
the exit and continue processing exits, which will cause us to process
the Init's exit before the exec, and emit it, which we don't want to do.

This commit introduces a map `s.pendingExecs` to keep track of the
number of pending execs keyed by container, which allows us to skip
processing exits for inits if there are pending execs, and instead
have the closure returned by `s.preStart` handle the init exit after
emitting the exec's exit.

Signed-off-by: Laura Brehm <laurabrehm@hey.com>
2024-03-01 16:43:19 +00:00
..
containerd Move events to plugins and core 2024-02-27 22:09:20 -08:00
containerd-shim-runc-v2 runc-shim: process exec exits before init 2024-03-01 16:43:19 +00:00
containerd-stress Convert CLI to urfave v2 2024-02-15 09:48:04 -08:00
ctr Move events to plugins and core 2024-02-27 22:09:20 -08:00
gen-manpages Convert CLI to urfave v2 2024-02-15 09:48:04 -08:00
protoc-gen-go-fieldpath go.mod: github.com/containerd/typeurl/v2 v2.1.0 2023-02-11 23:39:52 +09:00