{"record":{"id":"974259e60ae724e8","repo":"slimtoolkit/slim","slug":"pod-terminated","errorCode":null,"errorMessage":"Pod terminated","messagePattern":"Pod terminated","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/app/master/command/debug/handle_kubernetes_runtime.go","lineNumber":999,"sourceCode":"\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\nvar (\n\tErrPodTerminated       = errors.New(\"Pod terminated\")\n\tErrPodNotRunning       = errors.New(\"Pod not running\")\n\tErrContainerTerminated = errors.New(\"Container terminated\")\n)\n\nfunc waitForContainer(\n\tlogger *log.Entry,\n\txc *app.ExecutionContext,\n\tctx context.Context,\n\tapi *kubernetes.Clientset,\n\tnsName string,\n\tpodName string,\n\tcontainerName string,\n\tcontainerType string) error {\n\tlogger.Tracef(\"waitForContainer(%s,%s,%s,%s)\", nsName, podName, containerName, containerType)\n\n\tisContainerRunning := func() (bool, error) {\n\t\tpod, err := api.CoreV1().Pods(nsName).Get(ctx, podName, metav1.GetOptions{})\n\t\tif err != nil {","sourceCodeStart":981,"sourceCodeEnd":1017,"githubUrl":"https://github.com/slimtoolkit/slim/blob/81940d17fa112cc678e32209214bcb2355cb3004/pkg/app/master/command/debug/handle_kubernetes_runtime.go#L981-L1017","documentation":"ErrPodTerminated is returned by the Kubernetes debug runtime helpers in pkg/app/master/command/debug/handle_kubernetes_runtime.go when the target pod has terminated before or during the debug operation. Once a pod is terminated its containers cannot be inspected or debugged, so the handler aborts instead of waiting indefinitely.","triggerScenarios":"Running the debug (k8s runtime) command against a pod whose phase is Terminated/Succeeded/Failed; the pod exits while waitForContainer/listing active containers is in progress.","commonSituations":"Debugging a CrashLoopBackOff or completed Job pod; the workload finished right before the debug command attached; selecting the wrong pod name.","solutions":["Confirm the target pod is running: kubectl get pod <name> and check its phase","Re-run the debug command on an active pod or restart/patch the pod to keep it alive","For completed Jobs/CronJobs, debug a fresh running instance instead"],"exampleFix":null,"handlingStrategy":"validation","validationCode":"pod, _ := clientset.CoreV1().Pods(ns).Get(ctx, name, metav1.GetOptions{})\nif pod.Status.Phase != corev1.PodRunning {\n\treturn fmt.Errorf(\"pod %s is %s, cannot debug\", name, pod.Status.Phase)\n}","typeGuard":null,"tryCatchPattern":"// Go\nif errors.Is(err, ErrPodTerminated) {\n\t// surface to user: pick a running pod and retry\n}","preventionTips":["Check pod phase with kubectl before launching debug sessions","Avoid debugging completed Jobs/CronJob pods","Use kubectl wait --for=condition=Ready before attaching"],"tags":["kubernetes","pod","lifecycle"],"backgroundTag":"pod-terminated","analyzedSha":"81940d17fa112cc678e32209214bcb2355cb3004","analyzedAt":"2026-08-31T23:06:12.682Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T05:18:18.240Z"}