Skip to content

Commit 3124964

Browse files
committed
sandbox: fix recover status set issue
We can't set the status to Ready before task.Wait succeed. Signed-off-by: Abel Feng <[email protected]>
1 parent 96bf529 commit 3124964

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

internal/cri/server/podsandbox/recover.go

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -96,13 +96,17 @@ func (c *Controller) RecoverContainer(ctx context.Context, cntr containerd.Conta
9696
status.State = sandboxstore.StateNotReady
9797
} else {
9898
if taskStatus.Status == containerd.Running {
99-
status.State = sandboxstore.StateReady
100-
status.Pid = t.Pid()
10199
exitCh, err := t.Wait(ctrdutil.NamespacedContext())
102100
if err != nil {
103-
return status, channel, fmt.Errorf("failed to wait for sandbox container task: %w", err)
101+
if !errdefs.IsNotFound(err) {
102+
return status, channel, fmt.Errorf("failed to wait for sandbox container task: %w", err)
103+
}
104+
status.State = sandboxstore.StateNotReady
105+
} else {
106+
status.State = sandboxstore.StateReady
107+
status.Pid = t.Pid()
108+
channel = exitCh
104109
}
105-
channel = exitCh
106110
} else {
107111
// Task is not running. Delete the task and set sandbox state as NOTREADY.
108112
if _, err := t.Delete(ctx, containerd.WithProcessKill); err != nil && !errdefs.IsNotFound(err) {

0 commit comments

Comments
 (0)