Skip to content

Commit 74eb57b

Browse files
sagor999roboquat
authored andcommitted
[server] fix workspace PVC always restored from prebuild even if backup already exists
1 parent 715ed4b commit 74eb57b

File tree

1 file changed

+9
-6
lines changed

1 file changed

+9
-6
lines changed

components/server/src/workspace/workspace-starter.ts

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1435,14 +1435,17 @@ export class WorkspaceStarter {
14351435
}
14361436
}
14371437

1438-
const volumeSnapshotId =
1439-
(SnapshotContext.is(workspace.context) || WithPrebuild.is(workspace.context)) &&
1440-
!!workspace.context.snapshotBucketId
1441-
? workspace.context.snapshotBucketId
1442-
: lastValidWorkspaceInstanceId;
1438+
let volumeSnapshotId = ""
1439+
// always pick lastValidWorkspaceInstanceId if it is valid, otherwise workspace will be restored from prebuild
1440+
// even if there was workspace backup available
1441+
if (lastValidWorkspaceInstanceId != "") {
1442+
volumeSnapshotId = lastValidWorkspaceInstanceId
1443+
} else if ((SnapshotContext.is(workspace.context) || WithPrebuild.is(workspace.context)) && !!workspace.context.snapshotBucketId) {
1444+
volumeSnapshotId = workspace.context.snapshotBucketId
1445+
}
14431446

14441447
let volumeSnapshotInfo = new VolumeSnapshotInfo();
1445-
const volumeSnapshots = await this.workspaceDb.trace(traceCtx).findVolumeSnapshotById(volumeSnapshotId);
1448+
const volumeSnapshots = volumeSnapshotId != "" ? await this.workspaceDb.trace(traceCtx).findVolumeSnapshotById(volumeSnapshotId) : undefined;
14461449
if (volumeSnapshots !== undefined) {
14471450
log.info("starting workspace with volume snapshot info", {
14481451
lastInstanceId: lastValidWorkspaceInstanceId,

0 commit comments

Comments
 (0)