@@ -218,6 +218,40 @@ var _ = Describe("WorkspaceController", func() {
218218 })
219219 })
220220
221+ It ("should handle workspace failure with unknown exit code" , func () {
222+ ws := newWorkspace (uuid .NewString (), "default" )
223+ m := collectMetricCounts (wsMetrics , ws )
224+ pod := createWorkspaceExpectPod (ws )
225+
226+ markReady (ws )
227+
228+ // Update Pod with failed exit status.
229+ updateObjWithRetries (k8sClient , pod , true , func (pod * corev1.Pod ) {
230+ pod .Status .ContainerStatuses = append (pod .Status .ContainerStatuses , corev1.ContainerStatus {
231+ LastTerminationState : corev1.ContainerState {
232+ Terminated : & corev1.ContainerStateTerminated {
233+ ExitCode : containerUnknownExitCode ,
234+ },
235+ },
236+ })
237+ })
238+
239+ // Controller should detect container exit and add Failed condition.
240+ expectConditionEventually (ws , string (workspacev1 .WorkspaceConditionFailed ), metav1 .ConditionTrue , "" )
241+
242+ expectFinalizerAndMarkBackupCompleted (ws , pod )
243+
244+ expectWorkspaceCleanup (ws , pod )
245+
246+ expectMetricsDelta (m , collectMetricCounts (wsMetrics , ws ), metricCounts {
247+ restores : 1 ,
248+ startFailures : 0 ,
249+ failures : 1 ,
250+ stops : map [StopReason ]int {StopReasonFailed : 1 },
251+ backups : 1 ,
252+ })
253+ })
254+
221255 It ("should clean up timed out workspaces" , func () {
222256 ws := newWorkspace (uuid .NewString (), "default" )
223257 m := collectMetricCounts (wsMetrics , ws )
0 commit comments