Skip to content

Commit

Permalink
ws-manager: remove PVC object if the workspace pod fails to up
Browse files Browse the repository at this point in the history
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 <hsiaoairplane@gmail.com>
  • Loading branch information
jenting committed Oct 3, 2022
1 parent a0e056a commit 45ed281
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions components/ws-manager/pkg/manager/monitor.go
Original file line number Diff line number Diff line change
Expand Up @@ -300,6 +300,18 @@ func actOnPodEvent(ctx context.Context, m actingManager, manager *Manager, statu
return xerrors.Errorf("cannot stop workspace: %w", err)
}

// Delete PVC if it exists
// Note that: the PVC removal is postponed until the PVC is no longer actively used by its workspace pod.
// Therefore, the PVC is removed after the workspace pod finalizer is removed.
// No data loss unless we remove the workspace pod finalizer incorrectly.
_, createPVC := pod.Labels[pvcWorkspaceFeatureLabel]
if !createPVC {
return nil
}
err = manager.deleteWorkspacePVC(ctx, pod.Name)
if err != nil {
return xerrors.Errorf("cannot remove PVC: %w", err)
}
return nil
} else if status.Conditions.StoppedByRequest == api.WorkspaceConditionBool_TRUE {
span.LogKV("event", "stopped by request")
Expand Down

0 comments on commit 45ed281

Please sign in to comment.