Skip to content

Commit 39557c3

Browse files
jentingroboquat
authored andcommitted
[ws-manager] Only calculate the volume restore time if it's restoring from the VolumeSnapshot
Signed-off-by: JenTing Hsiao <[email protected]>
1 parent b60a6d7 commit 39557c3

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

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

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -217,7 +217,7 @@ func (m *Manager) StartWorkspace(ctx context.Context, req *api.StartWorkspaceReq
217217
var (
218218
createPVC bool
219219
pvc *corev1.PersistentVolumeClaim
220-
startTime, endTime time.Time
220+
startTime, endTime time.Time // the start time and end time of PVC restoring from VolumeSnapshot
221221
)
222222
for _, feature := range startContext.Request.Spec.FeatureFlags {
223223
if feature == api.WorkspaceFeatureFlag_PERSISTENT_VOLUME_CLAIM {
@@ -235,7 +235,10 @@ func (m *Manager) StartWorkspace(ctx context.Context, req *api.StartWorkspaceReq
235235
if err != nil && !k8serr.IsAlreadyExists(err) {
236236
return nil, xerrors.Errorf("cannot create pvc object for workspace pod: %w", err)
237237
}
238-
startTime = time.Now()
238+
// we only calculate the time that PVC restoring from VolumeSnapshot
239+
if startContext.VolumeSnapshot != nil && startContext.VolumeSnapshot.VolumeSnapshotName != "" {
240+
startTime = time.Now()
241+
}
239242
}
240243

241244
// create the Pod in the cluster and wait until is scheduled
@@ -266,7 +269,8 @@ func (m *Manager) StartWorkspace(ctx context.Context, req *api.StartWorkspaceReq
266269
return false, err
267270
}
268271

269-
if createPVC {
272+
// we only calculate the time that PVC restoring from VolumeSnapshot
273+
if createPVC && startContext.VolumeSnapshot != nil && startContext.VolumeSnapshot.VolumeSnapshotName != "" {
270274
err = wait.PollWithContext(ctx, 100*time.Millisecond, time.Minute, pvcRunning(m.Clientset, pvc.Name, pvc.Namespace))
271275
if err != nil {
272276
return false, nil

0 commit comments

Comments
 (0)