From 31249647432fc26d6fce332b827be55b46834b04 Mon Sep 17 00:00:00 2001 From: Abel Feng Date: Tue, 16 Jan 2024 15:47:30 +0800 Subject: [PATCH] sandbox: fix recover status set issue We can't set the status to Ready before task.Wait succeed. Signed-off-by: Abel Feng --- internal/cri/server/podsandbox/recover.go | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/internal/cri/server/podsandbox/recover.go b/internal/cri/server/podsandbox/recover.go index bd8c1fb56..1693c43c1 100644 --- a/internal/cri/server/podsandbox/recover.go +++ b/internal/cri/server/podsandbox/recover.go @@ -96,13 +96,17 @@ func (c *Controller) RecoverContainer(ctx context.Context, cntr containerd.Conta status.State = sandboxstore.StateNotReady } else { if taskStatus.Status == containerd.Running { - status.State = sandboxstore.StateReady - status.Pid = t.Pid() exitCh, err := t.Wait(ctrdutil.NamespacedContext()) if err != nil { - return status, channel, fmt.Errorf("failed to wait for sandbox container task: %w", err) + if !errdefs.IsNotFound(err) { + return status, channel, fmt.Errorf("failed to wait for sandbox container task: %w", err) + } + status.State = sandboxstore.StateNotReady + } else { + status.State = sandboxstore.StateReady + status.Pid = t.Pid() + channel = exitCh } - channel = exitCh } else { // Task is not running. Delete the task and set sandbox state as NOTREADY. if _, err := t.Delete(ctx, containerd.WithProcessKill); err != nil && !errdefs.IsNotFound(err) {