{"record":{"id":"e08ca422e4f0a398","repo":"slimtoolkit/slim","slug":"target-pod-is-not-running","errorCode":null,"errorMessage":"target pod is not running","messagePattern":"target pod is not running","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/app/master/command/debug/handle_kubernetes_runtime.go","lineNumber":120,"sourceCode":"\t\t\t\t\"pod\":    podName,\n\t\t\t\t\"status\": statusError.ErrStatus.Message,\n\t\t\t}).Error(\"ensurePod - status error\")\n\t\txc.FailOn(err)\n\t} else if err != nil {\n\t\tlogger.WithError(err).\n\t\t\tWithFields(log.Fields{\n\t\t\t\t\"ns\":     nsName,\n\t\t\t\t\"pod\":    podName,\n\t\t\t\t\"status\": statusError.ErrStatus.Message,\n\t\t\t}).Error(\"ensurePod - other error\")\n\t\txc.FailOn(err)\n\t}\n\n\tlogger.WithField(\"phase\", pod.Status.Phase).Debug(\"target pod status\")\n\n\tif pod.Status.Phase != corev1.PodRunning {\n\t\tlogger.Error(\"target pod is not running\")\n\t\txc.FailOn(fmt.Errorf(\"target pod is not running\"))\n\t}\n\n\tlogger.WithFields(\n\t\tlog.Fields{\n\t\t\t\"ns\":       nsName,\n\t\t\t\"pod\":      podName,\n\t\t\t\"ec.count\": len(pod.Spec.EphemeralContainers),\n\t\t}).Debug(\"target pod info\")\n\n\tif commandParams.ActionListDebuggableContainers {\n\t\txc.Out.State(\"action.list_debuggable_containers\",\n\t\t\tovars{\"namespace\": nsName, \"pod\": podName})\n\t\tresult, err := listK8sDebuggableContainers(ctx, api, nsName, podName)\n\t\tif err != nil {\n\t\t\tlogger.WithError(err).Error(\"listK8sDebuggableContainers\")\n\t\t\txc.FailOn(err)\n\t\t}\n","sourceCodeStart":102,"sourceCodeEnd":138,"githubUrl":"https://github.com/slimtoolkit/slim/blob/81940d17fa112cc678e32209214bcb2355cb3004/pkg/app/master/command/debug/handle_kubernetes_runtime.go#L102-L138","documentation":"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'.","triggerScenarios":"Calling the kubernetes runtime debug command while the target pod is still Pending (image pulling, scheduling), CrashLoopBackOff/restarting, Completed (job pods), or Evicted/Failed.","commonSituations":"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.","solutions":["Wait until the pod is Running: kubectl wait --for=condition=Ready pod/<name> -n <ns>","Diagnose why the pod is not running: kubectl describe pod and check events (image pull, scheduling, crashes)","Re-run the debug command against a pod that is currently running"],"exampleFix":"// before\nkubectl pilot debug --target pod/pending-pod  # fails: target pod is not running\n// after\nkubectl wait --for=condition=Ready pod/pending-pod && kubectl pilot debug --target pod/pending-pod","handlingStrategy":"retry","validationCode":"pod, _ := clientset.CoreV1().Pods(ns).Get(ctx, name, metav1.GetOptions{})\nif pod.Status.Phase != corev1.PodRunning {\n    return fmt.Errorf(\"pod %s/%s is %s; wait for Running before debugging\", ns, name, pod.Status.Phase)\n}","typeGuard":"func isPodRunning(p *corev1.Pod) bool { return p != nil && p.Status.Phase == corev1.PodRunning }","tryCatchPattern":"err := HandleKubernetesRuntime(...)\nif err != nil && strings.Contains(err.Error(), \"target pod is not running\") {\n    // retry with backoff until pod becomes Running or timeout\n    return retry.OnError(wait.Backoff{Steps: 10, Duration: 3 * time.Second},\n        func(err error) bool { return strings.Contains(err.Error(), \"not running\") }, handler)\n}","preventionTips":["Check pod phase/conditions before launching debug sessions","Use kubectl wait --for=condition=Ready as a gate","Don't target Completed job pods or evicted pods","Watch for image-pull and scheduling events that keep pods Pending"],"tags":["kubernetes","pod-state","precondition"],"backgroundTag":"pod-not-running","analyzedSha":"81940d17fa112cc678e32209214bcb2355cb3004","analyzedAt":"2026-08-31T23:06:12.682Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T05:18:18.240Z"}