GoogleContainerTools/skaffold · warning

waiting for init container %s to complete

Error message

waiting for init container %s to complete

What it means

This variant of the pod-initializing error (code STATUSCHECK_POD_INITIALIZING) means an init container has started and is Running but has not finished, so the main containers cannot begin. Skaffold fetches and returns the init container logs alongside the message to help diagnose why it is taking long.

Source

Thrown at pkg/diag/validator/validator.go:156

		sc, err := getUntoleratedTaints(c.Reason, c.Message)
		return sc, nil, err
	}
	// we can check the container status if the pod has been scheduled successfully. This can be determined by having the event
	// PodScheduled with status True, or a ContainerReady or PodReady event with status False.
	if isPodScheduledButNotReady(pod) {
		log.Entry(context.TODO()).Debugf("Pod %q scheduled but not ready: checking container statuses", pod.Name)
		// TODO(dgageot): Add EphemeralContainerStatuses
		cs := append(pod.Status.InitContainerStatuses, pod.Status.ContainerStatuses...)
		// See https://kubernetes.io/docs/concepts/workloads/pods/pod-lifecycle/#container-states
		statusCode, logs, err := getContainerStatus(pod, cs)
		if statusCode == proto.StatusCode_STATUSCHECK_POD_INITIALIZING {
			// Determine if an init container is still running and fetch the init logs.
			for _, c := range pod.Status.InitContainerStatuses {
				if c.State.Waiting != nil {
					return statusCode, []string{}, fmt.Errorf("waiting for init container %s to start", c.Name)
				} else if c.State.Running != nil {
					sc, l := getPodLogs(pod, c.Name, statusCode)
					return sc, l, fmt.Errorf("waiting for init container %s to complete", c.Name)
				}
			}
		}
		return statusCode, logs, err
	}

	if c, ok := isPodStatusUnknown(pod); ok {
		log.Entry(context.TODO()).Debugf("Pod %q condition status of type %s is unknown", pod.Name, c.Type)
		return proto.StatusCode_STATUSCHECK_UNKNOWN, nil, errors.New(c.Message)
	}

	log.Entry(context.TODO()).Debugf("Unable to determine current service state of pod %q", pod.Name)
	return proto.StatusCode_STATUSCHECK_UNKNOWN, nil, fmt.Errorf("unable to determine current service state of pod %q", pod.Name)
}

func isPodReady(pod *v1.Pod) bool {
	for _, c := range pod.Status.Conditions {
		if c.Type == v1.PodReady && c.Status == v1.ConditionTrue {

View on GitHub (pinned to a1189de023)

Solutions

  1. Read the returned init logs (or kubectl logs <pod> -c <init-container> -f) to see which step the init container is blocked on.
  2. If the init container waits on a dependency, fix that dependency (DB up, endpoint reachable, DNS resolving).
  3. Shorten or add a timeout/failure exit to the init script so the pod fails fast instead of hanging.
  4. Split heavy work out of initContainers into the app or a Job if it legitimately takes minutes.

Example fix

// before
// command: ["sh","-c","until nc -z db 5432; do sleep 1; done"] // loops forever if DNS broken
// after
// command: ["sh","-c","timeout 60 sh -c 'until nc -z db 5432; do sleep 1; done' || exit 1"]
Defensive patterns

Strategy: retry

Validate before calling

for _, ic := range pod.Status.InitContainerStatuses { if ic.State.Running != nil { tail, _ := getPodLogs(pod, ic.Name); fmt.Printf("init %s running, logs: %s", ic.Name, tail) } }

Type guard

func initContainersDone(pod *v1.Pod) bool { for _, c := range pod.Status.InitContainerStatuses { if c.State.Terminated == nil || c.State.Terminated.ExitCode != 0 { return false } } return len(pod.Status.InitContainerStatuses) > 0 }

Try / catch

status, logs, err := getPodStatus(pod); if errors.Is(err, errInitRunning) { select { case <-time.After(5 * time.Second): goto retry
	case <-ctx.Done(): return ctx.Err() } }

Prevention

When it happens

Trigger: getPodStatus finds an init container whose State.Running is non-nil; it calls getPodLogs for that container and returns 'waiting for init container <name> to complete'.

Common situations: Long-running init scripts (migrations, waits-for-dependency loops); init container looping on 'wait for DB/queue' checks that never succeed; very slow image or volume mounts; init script bug causing an infinite loop.

Related errors


AI-assisted analysis of GoogleContainerTools/skaffold@a1189de023 (2026-09-05). Data as JSON: /api/errors/ac967871510648a2. Report an issue: GitHub.