Skip to content

Commit fa3d8a3

Browse files
committed
[ws-manager-mk2] Extract headless task failure
1 parent 4f187cc commit fa3d8a3

File tree

2 files changed

+14
-3
lines changed

2 files changed

+14
-3
lines changed

components/ws-manager-mk2/controllers/status.go

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,10 @@ func (r *WorkspaceReconciler) updateWorkspaceStatus(ctx context.Context, workspa
148148
case pod.Status.Phase == corev1.PodRunning:
149149
var ready bool
150150
for _, cs := range pod.Status.ContainerStatuses {
151-
if cs.Ready {
151+
if cs.Ready || cs.State.Terminated != nil {
152+
// If container is terminated, it's been ready, we don't want to move back to initializing.
153+
// We will reconcile the termination state once the pod phase is updated to reflect the
154+
// terminated container.
152155
ready = true
153156
break
154157
}
@@ -259,7 +262,11 @@ func extractFailure(ws *workspacev1.Workspace, pod *corev1.Pod) (string, *worksp
259262
}
260263
} else if terminationState.Reason == "Completed" && !isPodBeingDeleted(pod) {
261264
if ws.IsHeadless() {
262-
// headless workspaces are expected to finish
265+
// headless workspaces are expected to finish. But if they have a termination message,
266+
// there was a failure.
267+
if terminationState.Message != "" {
268+
return terminationState.Message, nil
269+
}
263270
return "", nil
264271
}
265272
return fmt.Sprintf("container %s completed; containers of a workspace pod are not supposed to do that", cs.Name), nil

components/ws-manager-mk2/controllers/workspace_controller.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,11 @@ func (r *WorkspaceReconciler) Reconcile(ctx context.Context, req ctrl.Request) (
126126
r.updateMetrics(ctx, &workspace)
127127
r.emitPhaseEvents(ctx, &workspace, oldStatus)
128128

129-
log.V(1).Info("updating workspace status", "status", workspace.Status)
129+
var podStatus *corev1.PodStatus
130+
if len(workspacePods.Items) > 0 {
131+
podStatus = &workspacePods.Items[0].Status
132+
}
133+
log.Info("updating workspace status", "status", workspace.Status, "podStatus", podStatus)
130134
err = r.Status().Update(ctx, &workspace)
131135
if err != nil {
132136
// log.WithValues("status", workspace).Error(err, "unable to update workspace status")

0 commit comments

Comments
 (0)