Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test: add new test TestPrebuildAndRegularWorkspaceDifferentWorkspaceClass #13268

Merged
merged 2 commits into from
Sep 28, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions components/ws-manager/pkg/manager/manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -273,11 +273,30 @@ func (m *Manager) StartWorkspace(ctx context.Context, req *api.StartWorkspaceReq
clog.WithError(err).Error("was unable to restore volume snapshot")
return nil, err
}

// get again to update the volumeSnapshot variable
if err := m.Clientset.Get(ctx, types.NamespacedName{Namespace: m.Config.Namespace, Name: startContext.VolumeSnapshot.VolumeSnapshotName}, &volumeSnapshot); err != nil {
return nil, err
}
} else if err != nil {
clog.WithError(err).Error("was unable to get volume snapshot")
return nil, err
}

// check the PVC size is not less than the volume snapshot size
PVCConfig := m.Config.WorkspaceClasses[config.DefaultWorkspaceClass].PVC
if startContext.Class != nil {
PVCConfig = startContext.Class.PVC
}

if volumeSnapshot.Status != nil &&
volumeSnapshot.Status.RestoreSize != nil &&
PVCConfig.Size.Cmp(*volumeSnapshot.Status.RestoreSize) == -1 {
return nil, xerrors.Errorf("cannot restore volume snapshot from size %s to pvc size %s", volumeSnapshot.Status.RestoreSize.String(), PVCConfig.Size.String())
}
}

// create PVC object
pvc, err = m.createPVCForWorkspacePod(startContext)
if err != nil {
return nil, xerrors.Errorf("cannot create pvc for workspace pod: %w", err)
Expand Down
Loading