Skip to content
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

[release/1.7] Update runc-shim to process exec exits before init #9928

Merged

Conversation

laurazard
Copy link
Member

Backport #9828.


5cd6210 was also backported to 1.7, hence we should backport the fix to #9719.

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: containerd#9719).

Since 5cd6210, 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>
(cherry picked from commit 892dc54)
Signed-off-by: Laura Brehm <laurabrehm@hey.com>
@laurazard laurazard requested review from dmcgowan, cpuguy83, thaJeztah and a team March 5, 2024 03:42
@laurazard laurazard self-assigned this Mar 5, 2024
@laurazard
Copy link
Member Author

/retest

Copy link
Member

@thaJeztah thaJeztah left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@dmcgowan dmcgowan merged commit 69ca1b2 into containerd:release/1.7 Mar 5, 2024
56 checks passed
@dmcgowan dmcgowan changed the title [release/1.7] runc-shim: process exec exits before init [release/1.7] Update runc-shim to process exec exits before init Mar 8, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants