Skip to content

Commit

Permalink
fix: check workspace pod for unschedulable condition
Browse files Browse the repository at this point in the history
Fix devfile#977

Signed-off-by: Andrew Obuchowicz <[email protected]>
  • Loading branch information
AObuchow committed Nov 15, 2022
1 parent b95b453 commit ecf946c
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions pkg/library/status/check.go
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,12 @@ func CheckPodsState(workspaceID string, namespace string, labelSelector k8sclien
if msg, err := CheckPodEvents(&pod, workspaceID, ignoredEvents, clusterAPI); err != nil || msg != "" {
return msg, err
}
if pod.Status.Phase == corev1.PodPending {
if msg := checkPodConditions(&pod); msg != "" {
return msg, nil
}
}

}
return "", nil
}
Expand Down Expand Up @@ -164,3 +170,14 @@ func checkIfUnrecoverableEventIgnored(reason string, ignoredEvents []string) (ig
}
return false
}

func checkPodConditions(pod *corev1.Pod) (msg string) {
if pod.Status.Conditions != nil {
for _, condition := range pod.Status.Conditions {
if condition.Type == corev1.PodScheduled && condition.Status == corev1.ConditionFalse && condition.Reason == corev1.PodReasonUnschedulable {
return fmt.Sprintf("Pod is unschedulable: %s", condition.Message)
}
}
}
return ""
}

0 comments on commit ecf946c

Please sign in to comment.