{"record":{"id":"84f03ad165b77dfb","repo":"GoogleContainerTools/skaffold","slug":"pod-has-failed","errorCode":null,"errorMessage":"pod has failed","messagePattern":"pod has failed","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/skaffold/kubernetes/wait.go","lineNumber":94,"sourceCode":"\treturn func(event *watch.Event) (bool, error) {\n\t\tif event.Object == nil {\n\t\t\treturn false, nil\n\t\t}\n\t\tpod, isPod := event.Object.(*v1.Pod)\n\t\tif !isPod {\n\t\t\treturn false, nil\n\t\t}\n\t\tif pod.Name != podName {\n\t\t\treturn false, nil\n\t\t}\n\n\t\tswitch pod.Status.Phase {\n\t\tcase v1.PodSucceeded:\n\t\t\treturn true, nil\n\t\tcase v1.PodRunning:\n\t\t\treturn false, nil\n\t\tcase v1.PodFailed:\n\t\t\treturn false, errors.New(\"pod has failed\")\n\t\tcase v1.PodUnknown, v1.PodPending:\n\t\t\treturn false, nil\n\t\t}\n\t\treturn false, fmt.Errorf(\"unknown phase: %s\", pod.Status.Phase)\n\t}\n}\n\n// WaitForPodInitialized waits until init containers have started running\nfunc WaitForPodInitialized(ctx context.Context, pods corev1.PodInterface, podName string) error {\n\tlog.Entry(ctx).Infof(\"Waiting for %s to be initialized\", podName)\n\n\tw, err := newPodsWatcher(ctx, pods)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"initializing pod watcher: %s\", err)\n\t}\n\tdefer w.Stop()\n\n\treturn watchUntilTimeout(ctx, 10*time.Minute, w, func(event *watch.Event) (bool, error) {","sourceCodeStart":76,"sourceCodeEnd":112,"githubUrl":"https://github.com/GoogleContainerTools/skaffold/blob/a1189de023efc32d4b8e11f395acc678aa555011/pkg/skaffold/kubernetes/wait.go#L76-L112","documentation":"During pod wait, the callback inspects pod.Status.Phase and immediately fails the wait with \"pod has failed\" when the phase is PodFailed. It is used by deploy status checks that wait for a pod to reach Succeeded/Running and abort early on failure.","triggerScenarios":"Waiting on a pod whose status transitions to v1.PodFailed (container exited nonzero, failed init container, failed scheduler/eviction reporting Failure phase).","commonSituations":"Test pods or Jobs whose containers exit with a nonzero code; nodes evicting pods; images with bad entrypoints so the main container immediately dies.","solutions":["Run `kubectl describe pod <pod>` and check containerStatuses/state.exitCode for the failure reason","Fix the container command/entrypoint or the application error causing the nonzero exit","Check init containers and volumes (missing ConfigMaps/Secrets also fail pods) and re-run the deploy"],"exampleFix":"// before\ncommand: [\"/app/run.sh\"]\n// after\ncommand: [\"/bin/sh\", \"-c\", \"chmod +x /app/run.sh && /app/run.sh\"]  # fix failing entrypoint\n","handlingStrategy":"try-catch","validationCode":"// before waiting, verify pod spec sanity\nif pod.Spec.RestartPolicy == v1.RestartPolicyNever && isJobLike(pod) { /* failure = non-zero exit, handle explicitly */ }","typeGuard":"func podFailed(pod *v1.Pod) bool { return pod.Status.Phase == v1.PodFailed }","tryCatchPattern":"done, err := waitFn(pod)\nif err != nil && podFailed(pod) {\n  reason := firstContainerTerminationReason(pod) // e.g. Error, OOMKilled\n  return fmt.Errorf(\"pod %s failed (reason=%s): %w\", pod.Name, reason, err)\n}","preventionTips":["Set container commands/entrypoints that cannot exit immediately (chmod scripts, correct binary paths)","Check init containers and referenced ConfigMaps/Secrets exist","Keep restartPolicy consistent with the job intent"],"tags":["kubernetes","pod","wait"],"backgroundTag":"pod-failed-phase","analyzedSha":"a1189de023efc32d4b8e11f395acc678aa555011","analyzedAt":"2026-09-05T12:09:27.064Z","contentChangedAt":"2026-09-05T12:09:27.064Z","schemaVersion":2},"datasetVersion":"2026-09-12T17:17:11.597Z"}