From 9f4ba4883981ce07a50ceec9873d6440d283063f Mon Sep 17 00:00:00 2001 From: Maksym Pavlenko Date: Mon, 28 Nov 2022 13:29:21 -0800 Subject: [PATCH] [sandbox] Fix panic when waiting for sandbox controller Signed-off-by: Maksym Pavlenko --- pkg/cri/sbserver/sandbox_run.go | 23 +++++++++++++---------- 1 file changed, 13 insertions(+), 10 deletions(-) diff --git a/pkg/cri/sbserver/sandbox_run.go b/pkg/cri/sbserver/sandbox_run.go index d388ae2fe..ba830559a 100644 --- a/pkg/cri/sbserver/sandbox_run.go +++ b/pkg/cri/sbserver/sandbox_run.go @@ -296,17 +296,20 @@ func (c *criService) RunPodSandbox(ctx context.Context, r *runtime.RunPodSandbox // but we don't care about sandbox TaskOOM right now, so it is fine. go func() { resp, err := controller.Wait(context.Background(), id) - if err != nil && err != context.Canceled && err != context.DeadlineExceeded { - e := &eventtypes.TaskExit{ - ContainerID: id, - ID: id, - // Pid is not used - Pid: 0, - ExitStatus: resp.ExitStatus, - ExitedAt: resp.ExitedAt, - } - c.eventMonitor.backOff.enBackOff(id, e) + if err != nil { + log.G(ctx).WithError(err).Error("failed to wait for sandbox controller, skipping exit event") + return } + + e := &eventtypes.TaskExit{ + ContainerID: id, + ID: id, + // Pid is not used + Pid: 0, + ExitStatus: resp.ExitStatus, + ExitedAt: resp.ExitedAt, + } + c.eventMonitor.backOff.enBackOff(id, e) }() sandboxRuntimeCreateTimer.WithValues(labels["oci_runtime_type"]).UpdateSince(runtimeStart)