From 6d00c3ada8b094aa3a2aa73a396cd2243de3f59f Mon Sep 17 00:00:00 2001 From: Laura Brehm Date: Tue, 26 Mar 2024 13:17:07 +0000 Subject: [PATCH] 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 892dc54bd26f6e8b9aea4672208b1ba2158d8a1b 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, 892dc54bd26f6e8b9aea4672208b1ba2158d8a1b 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 --- cmd/containerd-shim-runc-v2/task/service.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/cmd/containerd-shim-runc-v2/task/service.go b/cmd/containerd-shim-runc-v2/task/service.go index 666e03603..448efdac9 100644 --- a/cmd/containerd-shim-runc-v2/task/service.go +++ b/cmd/containerd-shim-runc-v2/task/service.go @@ -678,7 +678,8 @@ func (s *service) processExits() { // process. var cps, skipped []containerProcess 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 { // This exit relates to a container for which we have pending execs. In // order to ensure order between execs and the init process for a given // container, skip processing this exit here and let the `handleStarted`