slimtoolkit/slim · error

target pod is not running

Error message

target pod is not running

What it means

HandleKubernetesRuntime, the k8s debug/steampipe runtime handler, fetches the target pod and requires it to be in the Running phase before attaching. If pod.Status.Phase is not corev1.PodRunning (e.g. Pending, Succeeded, Failed, Unknown), it fails the command with 'target pod is not running'.

Source

Thrown at pkg/app/master/command/debug/handle_kubernetes_runtime.go:120

				"pod":    podName,
				"status": statusError.ErrStatus.Message,
			}).Error("ensurePod - status error")
		xc.FailOn(err)
	} else if err != nil {
		logger.WithError(err).
			WithFields(log.Fields{
				"ns":     nsName,
				"pod":    podName,
				"status": statusError.ErrStatus.Message,
			}).Error("ensurePod - other error")
		xc.FailOn(err)
	}

	logger.WithField("phase", pod.Status.Phase).Debug("target pod status")

	if pod.Status.Phase != corev1.PodRunning {
		logger.Error("target pod is not running")
		xc.FailOn(fmt.Errorf("target pod is not running"))
	}

	logger.WithFields(
		log.Fields{
			"ns":       nsName,
			"pod":      podName,
			"ec.count": len(pod.Spec.EphemeralContainers),
		}).Debug("target pod info")

	if commandParams.ActionListDebuggableContainers {
		xc.Out.State("action.list_debuggable_containers",
			ovars{"namespace": nsName, "pod": podName})
		result, err := listK8sDebuggableContainers(ctx, api, nsName, podName)
		if err != nil {
			logger.WithError(err).Error("listK8sDebuggableContainers")
			xc.FailOn(err)
		}

View on GitHub (pinned to 81940d17fa)

Solutions

  1. Wait until the pod is Running: kubectl wait --for=condition=Ready pod/<name> -n <ns>
  2. Diagnose why the pod is not running: kubectl describe pod and check events (image pull, scheduling, crashes)
  3. Re-run the debug command against a pod that is currently running

Example fix

// before
kubectl pilot debug --target pod/pending-pod  # fails: target pod is not running
// after
kubectl wait --for=condition=Ready pod/pending-pod && kubectl pilot debug --target pod/pending-pod
Defensive patterns

Strategy: retry

Validate before calling

pod, _ := clientset.CoreV1().Pods(ns).Get(ctx, name, metav1.GetOptions{})
if pod.Status.Phase != corev1.PodRunning {
    return fmt.Errorf("pod %s/%s is %s; wait for Running before debugging", ns, name, pod.Status.Phase)
}

Type guard

func isPodRunning(p *corev1.Pod) bool { return p != nil && p.Status.Phase == corev1.PodRunning }

Try / catch

err := HandleKubernetesRuntime(...)
if err != nil && strings.Contains(err.Error(), "target pod is not running") {
    // retry with backoff until pod becomes Running or timeout
    return retry.OnError(wait.Backoff{Steps: 10, Duration: 3 * time.Second},
        func(err error) bool { return strings.Contains(err.Error(), "not running") }, handler)
}

Prevention

When it happens

Trigger: Calling the kubernetes runtime debug command while the target pod is still Pending (image pulling, scheduling), CrashLoopBackOff/restarting, Completed (job pods), or Evicted/Failed.

Common situations: Running a debug session immediately after `kubectl apply` before the pod is ready, targeting a finished job pod, cluster resource pressure keeping the pod Pending, or image pull errors.

Related errors


AI-assisted analysis of slimtoolkit/slim@81940d17fa (2026-08-31). Data as JSON: /api/errors/e08ca422e4f0a398. Report an issue: GitHub.