From 7458a10ca29ff2125626cd05100805c185dc8e2f Mon Sep 17 00:00:00 2001 From: Thomas Schubart Date: Wed, 7 Sep 2022 12:00:24 +0000 Subject: [PATCH] [server] Ensure PVC workspace class does not change --- .../server/src/workspace/workspace-classes.ts | 10 ++++++++++ .../server/src/workspace/workspace-starter.ts | 17 ++++++++++++++--- 2 files changed, 24 insertions(+), 3 deletions(-) diff --git a/components/server/src/workspace/workspace-classes.ts b/components/server/src/workspace/workspace-classes.ts index 9e68fe020fa470..fe64dc8c159b95 100644 --- a/components/server/src/workspace/workspace-classes.ts +++ b/components/server/src/workspace/workspace-classes.ts @@ -85,6 +85,11 @@ export namespace WorkspaceClasses { return getDefaultId(workspaceClasses); } + // todo: remove this once pvc has been rolled out + if (previousWorkspaceClass.endsWith("-pvc")) { + return previousWorkspaceClass; + } + const config = workspaceClasses.find((c) => c.id === previousWorkspaceClass); if (!config) { log.error( @@ -186,6 +191,11 @@ export namespace WorkspaceClasses { const current = classes.find((c) => c.id === currentClassId); let substitute = classes.find((c) => c.id === substituteClassId); + // todo: remove this once pvc has been rolled out + if (currentClassId.endsWith("-pvc")) { + return currentClassId; + } + if (current?.marker?.moreResources) { if (substitute?.marker?.moreResources) { return substitute?.id; diff --git a/components/server/src/workspace/workspace-starter.ts b/components/server/src/workspace/workspace-starter.ts index d51302b86eedec..26dff6ddafff84 100644 --- a/components/server/src/workspace/workspace-starter.ts +++ b/components/server/src/workspace/workspace-starter.ts @@ -903,9 +903,20 @@ export class WorkspaceStarter { featureFlags = featureFlags.concat(["workspace_class_limiting"]); } else { - workspaceClass = "default"; - if (await this.entitlementService.userGetsMoreResources(user)) { - workspaceClass = "gitpodio-internal-xl"; + // todo: remove this once pvc has been rolled out + const prebuildClass = await WorkspaceClasses.getFromPrebuild( + ctx, + workspace, + this.workspaceDb.trace(ctx), + ); + if (prebuildClass?.endsWith("-pvc")) { + workspaceClass = prebuildClass; + // #### + } else { + workspaceClass = "default"; + if (await this.entitlementService.userGetsMoreResources(user)) { + workspaceClass = "gitpodio-internal-xl"; + } } }