func getPodErrors()

in pkg/controllers/common_utils.go [152:184]


func getPodErrors(pod *corev1.Pod) (errs []string) {

	podReadyCondition := getPodCondition(pod, corev1.PodReady)
	if podReadyCondition != nil && podReadyCondition.Status == corev1.ConditionTrue {
		// Pod is ready => no error
		return nil
	}

	// Check if the pod has been scheduled
	podScheduledCondition := getPodCondition(pod, corev1.PodScheduled)
	if podScheduledCondition == nil {
		// Pod has been just added
		return nil
	} else if podScheduledCondition.Status != corev1.ConditionTrue {
		// Pod is not scheduled yet.
		// Check if it is unschedulable.
		if podScheduledCondition.Reason == corev1.PodReasonUnschedulable {
			// This pod is unschedulable due to some reason
			return []string{fmt.Sprintf("pod %q is unschedulable : %s",
				getNamespacedName(pod), podScheduledCondition.Message)}
		}

		// Pod has not been scheduled yet, but it is not unschedulable => no error
		return nil
	}

	// Pod has been scheduled but not ready.
	// Some or all of the containers must have been started.
	// Retrieve and return any errors from them
	errs = append(errs, checkContainersForError(pod.Status.InitContainerStatuses, pod.Name)...)
	errs = append(errs, checkContainersForError(pod.Status.ContainerStatuses, pod.Name)...)
	return errs
}