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

[server] fix workspace PVC always restored from prebuild even if backup already exists #12180

Merged
merged 1 commit into from
Aug 18, 2022
Merged
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
15 changes: 9 additions & 6 deletions components/server/src/workspace/workspace-starter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1435,14 +1435,17 @@ export class WorkspaceStarter {
}
}

const volumeSnapshotId =
(SnapshotContext.is(workspace.context) || WithPrebuild.is(workspace.context)) &&
!!workspace.context.snapshotBucketId
? workspace.context.snapshotBucketId
: lastValidWorkspaceInstanceId;
let volumeSnapshotId = ""
// always pick lastValidWorkspaceInstanceId if it is valid, otherwise workspace will be restored from prebuild
// even if there was workspace backup available
if (lastValidWorkspaceInstanceId != "") {
volumeSnapshotId = lastValidWorkspaceInstanceId
} else if ((SnapshotContext.is(workspace.context) || WithPrebuild.is(workspace.context)) && !!workspace.context.snapshotBucketId) {
volumeSnapshotId = workspace.context.snapshotBucketId
}

let volumeSnapshotInfo = new VolumeSnapshotInfo();
const volumeSnapshots = await this.workspaceDb.trace(traceCtx).findVolumeSnapshotById(volumeSnapshotId);
const volumeSnapshots = volumeSnapshotId != "" ? await this.workspaceDb.trace(traceCtx).findVolumeSnapshotById(volumeSnapshotId) : undefined;
if (volumeSnapshots !== undefined) {
log.info("starting workspace with volume snapshot info", {
lastInstanceId: lastValidWorkspaceInstanceId,
Expand Down