containerd/containerd · error

failed to get task status: %w

Error message

failed to get task status: %w

What it means

When the task handle loads successfully during sandbox recovery, the code calls t.Status(ctx) to get its current state. If Status fails with a non-NotFound error, it is wrapped with this message. Since the task existed a moment earlier, a NotFound here is treated as the task being deleted in the window; any other error indicates a real failure querying task state from the shim/containerd.

Source

Thrown at internal/cri/server/podsandbox/recover.go:114

		status.CreatedAt = info.CreatedAt

		// Load sandbox state.
		t, err := cntr.Task(ctx, nil)
		if err != nil && !errdefs.IsNotFound(err) {
			return status, channel, fmt.Errorf("failed to load task: %w", err)
		}
		var taskStatus containerd.Status
		var notFound bool
		if errdefs.IsNotFound(err) {
			// Task is not found.
			notFound = true
		} else {
			// Task is found. Get task status.
			taskStatus, err = t.Status(ctx)
			if err != nil {
				// It's still possible that task is deleted during this window.
				if !errdefs.IsNotFound(err) {
					return status, channel, fmt.Errorf("failed to get task status: %w", err)
				}
				notFound = true
			}
		}
		if notFound {
			// Task does not exist, set sandbox state as NOTREADY.
			status.State = sandboxstore.StateNotReady
		} else {
			if taskStatus.Status == containerd.Running {
				exitCh, err := t.Wait(ctrdutil.NamespacedContext())
				if err != nil {
					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()

View on GitHub (pinned to 4246446a2b)

Solutions

  1. Inspect the wrapped error for RPC/transport vs shim crash causes
  2. Restart containerd so it reconnects to or cleans up shims, then allow recovery to re-run
  3. Check node resources (fds, memory) and shim logs (journalctl -u containerd) for the failing shim
  4. If the shim is unrecoverable, delete the sandbox container record and let the kubelet recreate the pod
Defensive patterns

Strategy: retry

Try / catch

taskStatus, err = t.Status(ctx)
if err != nil && !errdefs.IsNotFound(err) {
  // retry once after reconnect; transient shim RPC failures often clear
  time.Sleep(100 * time.Millisecond)
  taskStatus, err = t.Status(ctx)
  if err != nil && !errdefs.IsNotFound(err) {
    return fmt.Errorf("failed to get task status: %w", err)
  }
}

Prevention

When it happens

Trigger: RecoverContainer startup path: t.Status(ctx) returns e.g. an RPC timeout, shim IO error, or transport failure while talking to the sandbox's shim process.

Common situations: Shim process hung or dead but task record still present; containerd-to-shim connection broken after daemon restart; resource exhaustion (fd/memory) on the node causing RPC failures.

Related errors


AI-assisted analysis of containerd/containerd@4246446a2b (2026-09-02). Data as JSON: /api/errors/4b15b5eabaa26e7a. Report an issue: GitHub.