Skip to content

Commit a5df1cb

Browse files
authored
Revert "Remove workspace_classes_backend feature flag (#16825)" (#16854)
This reverts commit afb7246.
1 parent 97f8d4b commit a5df1cb

File tree

2 files changed

+33
-2
lines changed

2 files changed

+33
-2
lines changed

components/ws-manager-bridge/src/cluster-service-server.ts

Lines changed: 28 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,8 @@ import { getSupportedWorkspaceClasses } from "./cluster-sync-service";
4444
import { Configuration } from "./config";
4545
import { GRPCError } from "./rpc";
4646
import { isWorkspaceRegion } from "@gitpod/gitpod-protocol/lib/workspace-cluster";
47+
import { getExperimentsClientForBackend } from "@gitpod/gitpod-protocol/lib/experiments/configcat-server";
48+
import { GetWorkspacesRequest, WorkspaceManagerClient } from "@gitpod/ws-manager/lib";
4749

4850
export interface ClusterServiceServerOptions {
4951
port: number;
@@ -148,8 +150,32 @@ export class ClusterService implements IClusterServiceServer {
148150
tls,
149151
};
150152

151-
let classConstraints = await getSupportedWorkspaceClasses(this.clientProvider, newCluster, false);
152-
newCluster.admissionConstraints = admissionConstraints.concat(classConstraints);
153+
const enabled = await getExperimentsClientForBackend().getValueAsync(
154+
"workspace_classes_backend",
155+
false,
156+
{},
157+
);
158+
if (enabled) {
159+
let classConstraints = await getSupportedWorkspaceClasses(this.clientProvider, newCluster, false);
160+
newCluster.admissionConstraints = admissionConstraints.concat(classConstraints);
161+
} else {
162+
// try to connect to validate the config. Throws an exception if it fails.
163+
await new Promise<void>((resolve, reject) => {
164+
const c = this.clientProvider.createConnection(WorkspaceManagerClient, newCluster);
165+
c.getWorkspaces(new GetWorkspacesRequest(), (err: any) => {
166+
if (err) {
167+
reject(
168+
new GRPCError(
169+
grpc.status.FAILED_PRECONDITION,
170+
`cannot reach ${req.url}: ${err.message}`,
171+
),
172+
);
173+
} else {
174+
resolve();
175+
}
176+
});
177+
});
178+
}
153179

154180
await this.clusterDB.save(newCluster);
155181
log.info({}, "cluster registered", { cluster: req.name });

components/ws-manager-bridge/src/cluster-sync-service.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,11 @@ export class ClusterSyncService {
4242
}
4343

4444
private async reconcile() {
45+
const enabled = await this.featureClient.getValueAsync("workspace_classes_backend", false, {});
46+
if (!enabled) {
47+
return;
48+
}
49+
4550
log.debug("reconciling workspace classes...");
4651
let allClusters = await this.clusterDB.findFiltered({});
4752
for (const cluster of allClusters) {

0 commit comments

Comments
 (0)