Commit Graph

10 Commits

Author SHA1 Message Date
Laura Brehm
6d00c3ada8
runc-shim: only defer init process exits
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 892dc54bd2 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,
892dc54bd2 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>
2024-03-26 13:39:11 +00:00
Maksym Pavlenko
6a96e45012
Move shim package to pkg
Signed-off-by: Maksym Pavlenko <pavlenko.maksym@gmail.com>
2024-03-07 10:05:26 -08:00
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
Derek McGowan
fb9b59a843
Switch to new errdefs package
Signed-off-by: Derek McGowan <derek@mcg.dev>
2024-01-25 22:18:45 -08:00
Derek McGowan
dbc74db6a1
Move runtime to core/runtime
Signed-off-by: Derek McGowan <derek@mcg.dev>
2024-01-17 09:58:04 -08:00
Derek McGowan
6be90158cd
Move sys to pkg/sys
Signed-off-by: Derek McGowan <derek@mcg.dev>
2024-01-17 09:56:16 -08:00
Derek McGowan
fa8cae99d1
Move namespaces to pkg/namespaces
Signed-off-by: Derek McGowan <derek@mcg.dev>
2024-01-17 09:55:39 -08:00
Derek McGowan
44a836c9b5
Move errdefs to pkg/errdefs
Signed-off-by: Derek McGowan <derek@mcg.dev>
2024-01-17 09:54:45 -08:00
Akihiro Suda
8e567aa581
mv pkg/process cmd/containerd-shim-runc-v2/process
The package is quite specific to runc and only imported by
containerd-shim-runc-v2

Signed-off-by: Akihiro Suda <akihiro.suda.cz@hco.ntt.co.jp>
2023-11-30 21:50:04 +09:00
Maksym Pavlenko
7d65a45639
Move runc shim implementation to cmd
Signed-off-by: Maksym Pavlenko <pavlenko.maksym@gmail.com>
2023-11-14 10:13:32 -08:00