Skip to content

Commit 28fae90

Browse files
jentingroboquat
authored andcommitted
ws-manager: remove PVC object if the workspace pod fails to up
Remove the PVC object if the stop workspace request. The PVC object removal is postponed until the PVC is no longer actively used by the workspace pod. Signed-off-by: JenTing Hsiao <[email protected]>
1 parent f4a71fa commit 28fae90

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

components/ws-manager/pkg/manager/monitor.go

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -300,6 +300,18 @@ func actOnPodEvent(ctx context.Context, m actingManager, manager *Manager, statu
300300
return xerrors.Errorf("cannot stop workspace: %w", err)
301301
}
302302

303+
// Delete PVC if it exists
304+
// Note that: the PVC removal is postponed until the PVC is no longer actively used by its workspace pod.
305+
// Therefore, the PVC is removed after the workspace pod finalizer is removed.
306+
// No data loss unless we remove the workspace pod finalizer incorrectly.
307+
_, createPVC := pod.Labels[pvcWorkspaceFeatureLabel]
308+
if !createPVC {
309+
return nil
310+
}
311+
err = manager.deleteWorkspacePVC(ctx, pod.Name)
312+
if err != nil {
313+
return xerrors.Errorf("cannot remove PVC: %w", err)
314+
}
303315
return nil
304316
} else if status.Conditions.StoppedByRequest == api.WorkspaceConditionBool_TRUE {
305317
span.LogKV("event", "stopped by request")

0 commit comments

Comments
 (0)