{"record":{"id":"eccb8d36d985be13","repo":"slimtoolkit/slim","slug":"ephemeral-container-not-found","errorCode":null,"errorMessage":"ephemeral container not found","messagePattern":"ephemeral container not found","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/app/master/command/debug/handle_kubernetes_runtime.go","lineNumber":482,"sourceCode":"\t\tPods(pod.Namespace).\n\t\tGet(ctx, pod.Name, metav1.GetOptions{})\n\tif err != nil {\n\t\tlogger.WithError(err).Error(\"error getting the ephemeral container from target pod\")\n\t\txc.FailOn(err)\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\"target\": commandParams.TargetRef,\n\t\t\t\"image\":  commandParams.DebugContainerImage,\n\t\t}).Debug(\"attached ephemeral container\")\n\n\tec := ephemeralContainerFromPod(updatedPod, commandParams.TargetRef, debugContainerName)\n\tif ec == nil {\n\t\tlogger.Errorf(\"ephemeral container not found in pod\")\n\t\txc.FailOn(fmt.Errorf(\"ephemeral container not found\"))\n\t}\n\n\tecData, _ := json.Marshal(ec)\n\tlogger.WithField(\"data\", string(ecData)).Trace(\"ephemeral container\")\n\n\tvar ecContainerIsRunning bool\n\tfor _, ecStatus := range updatedPod.Status.EphemeralContainerStatuses {\n\t\tif ecStatus.Name == debugContainerName {\n\t\t\tif ecStatus.State.Running != nil {\n\t\t\t\tecContainerIsRunning = true\n\t\t\t}\n\t\t\tbreak\n\t\t}\n\t}\n\n\tif !ecContainerIsRunning {\n\t\txc.Out.Info(\"wait.for.debug.container\",\n\t\t\tovars{","sourceCodeStart":464,"sourceCodeEnd":500,"githubUrl":"https://github.com/slimtoolkit/slim/blob/81940d17fa112cc678e32209214bcb2355cb3004/pkg/app/master/command/debug/handle_kubernetes_runtime.go#L464-L500","documentation":"After attaching a debug (ephemeral) container to the pod and updating it via the Kubernetes API, the tool re-reads the pod and looks up the ephemeral container by the generated debug container name. If the updated pod does not contain that ephemeral container, the command fails. This usually means the ephemeral container was never actually admitted or attached.","triggerScenarios":"HandleKubernetesRuntime attaches an ephemeral container, calls Update on the pod, then ephemeralContainerFromPod(updatedPod, targetRef, debugContainerName) returns nil because the pod's ephemeralContainerStatuses/spec lack the expected container.","commonSituations":"Kubernetes API server silently dropped the ephemeral container (feature gate EphemeralContainers disabled, k8s < 1.23 behavior differences); RBAC denies updating pod/ephemeralcontainers so the update fails or is ignored; managed clusters (some managed K8s flavors) restrict ephemeral containers; image pull rejected so the container never appears in statuses.","solutions":["Verify cluster Kubernetes version >= 1.23 (GA) or that the EphemeralContainers feature gate is enabled.","Check RBAC: the credentials need 'update' on 'pods/ephemeralcontainers' (`kubectl auth can-i update pods/ephemeralcontainers`).","Inspect the pod after the attempt (`kubectl get pod <pod> -o yaml`) to see if the ephemeral container was admitted or rejected and why.","Retry with a different --debug-container image that is pullable from the cluster."],"exampleFix":"// before (k8s 1.20, no support)\nslim debug pod/myapp --target app\n// after: upgrade cluster to >=1.23 or use kubectl debug on a supported cluster\nkubectl debug -it myapp --image=busybox --target=app","handlingStrategy":"validation","validationCode":"kubectl version --short  # require server >= 1.23\nkubectl auth can-i update pods/ephemeralcontainers --all-namespaces","typeGuard":null,"tryCatchPattern":"if err := runDebug(target); err != nil && strings.Contains(err.Error(), \"ephemeral container not found\") {\n    // fall back to `kubectl debug` or node-level debugging\n}","preventionTips":["Confirm EphemeralContainers GA support on the cluster","Verify RBAC for pods/ephemeralcontainers before automation","Use pullable, small debug images (busybox)"],"tags":["kubernetes","ephemeral-container","debug"],"backgroundTag":"ephemeral-container-missing","analyzedSha":"81940d17fa112cc678e32209214bcb2355cb3004","analyzedAt":"2026-08-31T23:06:12.682Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T05:18:18.240Z"}