{"record":{"id":"9eb4db288589d809","repo":"slimtoolkit/slim","slug":"pod-is-done","errorCode":null,"errorMessage":"pod is done","messagePattern":"pod is done","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/app/master/command/debug/handle_kubernetes_runtime.go","lineNumber":979,"sourceCode":"\t\t\treturn nil, \"\", fmt.Errorf(\"no pods\")\n\t\t}\n\n\t\tpodName = pods.Items[0].Name\n\t}\n\n\tvar outputPod *corev1.Pod\n\tisPodRunning := func() (bool, error) {\n\t\tpod, err := api.CoreV1().Pods(nsName).Get(ctx, podName, metav1.GetOptions{})\n\t\tif err != nil {\n\t\t\treturn false, err\n\t\t}\n\n\t\tswitch pod.Status.Phase {\n\t\tcase corev1.PodRunning:\n\t\t\toutputPod = pod\n\t\t\treturn true, nil\n\t\tcase corev1.PodFailed, corev1.PodSucceeded:\n\t\t\treturn false, fmt.Errorf(\"pod is done\")\n\t\t}\n\t\treturn false, nil\n\t}\n\n\terr := wait.PollImmediate(2*time.Second, 2*time.Minute, isPodRunning)\n\tif err != nil {\n\t\treturn nil, \"\", err\n\t}\n\n\treturn outputPod, podName, nil\n}\n\nconst (\n\tctInit      = \"init\"\n\tctStandard  = \"standard\"\n\tctEphemeral = \"ephemeral\"\n)\n","sourceCodeStart":961,"sourceCodeEnd":997,"githubUrl":"https://github.com/slimtoolkit/slim/blob/81940d17fa112cc678e32209214bcb2355cb3004/pkg/app/master/command/debug/handle_kubernetes_runtime.go#L961-L997","documentation":"ensurePod waits (PollImmediate, up to 2 minutes) for the selected pod to reach the Running phase before attaching the debug container. If the pod reaches Failed or Succeeded instead, the wait aborts with 'pod is done'. The pod has terminated in a terminal state, so debugging its runtime is impossible.","triggerScenarios":"ensurePod's isPodRunning poll callback observes pod.Status.Phase == PodFailed or PodSucceeded during the 2-minute polling window.","commonSituations":"Debugging a Job/CronJob pod whose container already exited successfully (Succeeded); a CrashLoopBackOff pod that transitions to Failed; pending pod that fails scheduling and reports Failed; short-lived init-job pods.","solutions":["Check `kubectl describe pod <pod>` for the terminal reason (exit code, scheduling failure) and fix the workload first.","Target a long-running pod (e.g., the deployment's ReplicaSet pod) rather than a completed Job pod.","For crash-looping pods, fix the container crash before attempting a debug session.","If the pod completed as part of a job, re-run the job and attach the debug session immediately, or use ephemeral debugging on a freshly started pod."],"exampleFix":"// before: targeting a finished job pod\nslim debug myjob-abcde --target worker\n// after: target the live deployment pod\nslim debug myapp-5d7f8c6b9-x2klm --target app","handlingStrategy":"validation","validationCode":"phase=$(kubectl get pod myapp-pod -o jsonpath='{.status.phase}')\n[ \"$phase\" = \"Running\" ] || echo \"pod phase is $phase — aborting debug\"","typeGuard":null,"tryCatchPattern":"if err := runDebug(target); err != nil && strings.Contains(err.Error(), \"pod is done\") {\n    // inspect kubectl describe pod for terminal reason\n}","preventionTips":["Only target pods in Running phase","Avoid debugging completed Job pods — target live ReplicaSet pods","Fix CrashLoopBackOff before attaching debuggers"],"tags":["kubernetes","pod-lifecycle","debug"],"backgroundTag":"pod-terminated","analyzedSha":"81940d17fa112cc678e32209214bcb2355cb3004","analyzedAt":"2026-08-31T23:06:12.682Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T05:18:18.240Z"}