From 890398677ec64c50c146eb79fe9355f1224cef52 Mon Sep 17 00:00:00 2001 From: Samuel Karp Date: Fri, 14 Oct 2022 14:39:52 -0700 Subject: [PATCH] cri: PodSandboxStatus should tolerate missing task Signed-off-by: Samuel Karp --- pkg/cri/sbserver/sandbox_status.go | 12 +++++++----- pkg/cri/server/sandbox_status.go | 12 +++++++----- 2 files changed, 14 insertions(+), 10 deletions(-) diff --git a/pkg/cri/sbserver/sandbox_status.go b/pkg/cri/sbserver/sandbox_status.go index 3f21e8800..a9508451e 100644 --- a/pkg/cri/sbserver/sandbox_status.go +++ b/pkg/cri/sbserver/sandbox_status.go @@ -155,12 +155,14 @@ func toCRISandboxInfo(ctx context.Context, sandbox sandboxstore.Sandbox) (map[st var processStatus containerd.ProcessStatus if task != nil { - taskStatus, err := task.Status(ctx) - if err != nil { - return nil, fmt.Errorf("failed to get task status: %w", err) + if taskStatus, err := task.Status(ctx); err != nil { + if !errdefs.IsNotFound(err) { + return nil, fmt.Errorf("failed to get task status: %w", err) + } + processStatus = containerd.Unknown + } else { + processStatus = taskStatus.Status } - - processStatus = taskStatus.Status } si := &SandboxInfo{ diff --git a/pkg/cri/server/sandbox_status.go b/pkg/cri/server/sandbox_status.go index 6deb23ef5..bc1a2075a 100644 --- a/pkg/cri/server/sandbox_status.go +++ b/pkg/cri/server/sandbox_status.go @@ -155,12 +155,14 @@ func toCRISandboxInfo(ctx context.Context, sandbox sandboxstore.Sandbox) (map[st var processStatus containerd.ProcessStatus if task != nil { - taskStatus, err := task.Status(ctx) - if err != nil { - return nil, fmt.Errorf("failed to get task status: %w", err) + if taskStatus, err := task.Status(ctx); err != nil { + if !errdefs.IsNotFound(err) { + return nil, fmt.Errorf("failed to get task status: %w", err) + } + processStatus = containerd.Unknown + } else { + processStatus = taskStatus.Status } - - processStatus = taskStatus.Status } si := &SandboxInfo{