Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions components/operator/internal/handlers/reconciler.go
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,8 @@ func UpdateSessionFromPodStatus(ctx context.Context, session *unstructured.Unstr
Reason: "Scheduled",
Message: fmt.Sprintf("Scheduled on %s", pod.Spec.NodeName),
})
} else {
surfacePodSchedulingFailure(pod, statusPatch)
}

switch pod.Status.Phase {
Expand Down Expand Up @@ -346,6 +348,24 @@ func EnsureFreshRunnerToken(ctx context.Context, session *unstructured.Unstructu
return ensureFreshRunnerToken(ctx, session)
}

// surfacePodSchedulingFailure checks pod conditions for scheduling failures
// and adds a PodScheduled=False condition to the status patch if found.
// This surfaces messages like "0/1 nodes are available: 1 Insufficient memory"
// so users can see why their session is stuck in Creating.
func surfacePodSchedulingFailure(pod *corev1.Pod, statusPatch *StatusPatch) {
for _, cond := range pod.Status.Conditions {
if cond.Type == corev1.PodScheduled && cond.Status == corev1.ConditionFalse {
statusPatch.AddCondition(conditionUpdate{
Type: conditionPodScheduled,
Status: "False",
Reason: string(cond.Reason),
Message: cond.Message,
})
return
}
}
}

// collectPodErrorMessage extracts detailed error information from a failed pod.
func collectPodErrorMessage(pod *corev1.Pod) string {
errorMsg := pod.Status.Message
Expand Down
2 changes: 2 additions & 0 deletions components/operator/internal/handlers/sessions.go
Original file line number Diff line number Diff line change
Expand Up @@ -1755,6 +1755,8 @@ func monitorPod(podName, sessionName, sessionNamespace string) {

if pod.Spec.NodeName != "" {
statusPatch.AddCondition(conditionUpdate{Type: conditionPodScheduled, Status: "True", Reason: "Scheduled", Message: fmt.Sprintf("Scheduled on %s", pod.Spec.NodeName)})
} else {
surfacePodSchedulingFailure(pod, statusPatch)
}

if pod.Status.Phase == corev1.PodSucceeded {
Expand Down
Loading