Skip to content

Commit e6605c2

Browse files
committed
[ws-daemon] start backup even pod still report the container is running after 5 minutes
1 parent e8fff57 commit e6605c2

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

components/ws-daemon/pkg/controller/workspace_controller.go

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -349,9 +349,15 @@ func (wsc *WorkspaceController) doWorkspaceContentBackup(ctx context.Context, sp
349349

350350
if ws.IsConditionTrue(workspacev1.WorkspaceConditionContainerRunning) {
351351
// Container is still running, we need to wait for it to stop.
352-
// We should get an event when the condition changes, but requeue
353-
// anyways to make sure we act on it in time.
354-
return ctrl.Result{RequeueAfter: 500 * time.Millisecond}, nil
352+
// We will wait for this situation for up to 5 minutes.
353+
// If the container is still in a running state after that,
354+
// there may be an issue with state synchronization.
355+
// We should start backup anyway to avoid data loss.
356+
if !(ws.DeletionTimestamp != nil && time.Since(ws.DeletionTimestamp.Time) > 5*time.Minute) {
357+
// We should get an event when the condition changes, but requeue
358+
// anyways to make sure we act on it in time.
359+
return ctrl.Result{RequeueAfter: 500 * time.Millisecond}, nil
360+
}
355361
}
356362

357363
if wsc.latestWorkspace(ctx, ws) != nil {

0 commit comments

Comments
 (0)