Skip to content

Commit eddd393

Browse files
Andrew Farriesroboquat
Andrew Farries
authored andcommitted
Make applicationCluster mandatory when filtering
1 parent 2ede9de commit eddd393

File tree

5 files changed

+16
-11
lines changed

5 files changed

+16
-11
lines changed

components/gitpod-db/src/typeorm/workspace-cluster-db-impl.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
* See License-AGPL.txt in the project root for license information.
55
*/
66

7-
import { Repository, EntityManager, DeepPartial } from "typeorm";
7+
import { Repository, EntityManager } from "typeorm";
88
import { injectable, inject } from "inversify";
99
import { TypeORM } from "./typeorm";
1010
import { WorkspaceClusterDB } from "../workspace-cluster-db";
@@ -42,7 +42,7 @@ export class WorkspaceClusterDBImpl implements WorkspaceClusterDB {
4242
return repo.findOne(name);
4343
}
4444

45-
async findFiltered(predicate: DeepPartial<WorkspaceClusterFilter>): Promise<WorkspaceClusterWoTLS[]> {
45+
async findFiltered(predicate: WorkspaceClusterFilter): Promise<WorkspaceClusterWoTLS[]> {
4646
const prototype: WorkspaceClusterWoTLS = {
4747
name: "",
4848
url: "",

components/gitpod-db/src/workspace-cluster-db.spec.db.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ export class WorkspaceClusterDBSpec {
5555
await this.db.save(wsc1);
5656
await this.db.save(wsc2);
5757

58-
const wscs = await this.db.findFiltered({ name: "eu71" });
58+
const wscs = await this.db.findFiltered({ name: "eu71", applicationCluster: "eu02" });
5959
expect(wscs.length).to.equal(1);
6060
expect(wscs[0].name).to.equal("eu71");
6161
}

components/gitpod-protocol/src/workspace-cluster.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -102,9 +102,9 @@ export interface WorkspaceClusterDB {
102102
* Lists all WorkspaceClusterWoTls for which the given predicate is true (does not return TLS for size/speed concerns)
103103
* @param predicate
104104
*/
105-
findFiltered(predicate: DeepPartial<WorkspaceClusterFilter>): Promise<WorkspaceClusterWoTLS[]>;
106-
}
107-
export interface WorkspaceClusterFilter
108-
extends Pick<WorkspaceCluster, "name" | "state" | "govern" | "url" | "applicationCluster"> {
109-
minScore: number;
105+
findFiltered(predicate: WorkspaceClusterFilter): Promise<WorkspaceClusterWoTLS[]>;
110106
}
107+
108+
export type WorkspaceClusterFilter = Pick<WorkspaceCluster, "applicationCluster"> &
109+
DeepPartial<Pick<WorkspaceCluster, "name" | "state" | "govern" | "url">> &
110+
Partial<{ minScore: number }>;

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

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,10 @@ export class ClusterService implements IClusterServiceServer {
8888
const req = call.request.toObject();
8989

9090
const clusterByNamePromise = this.clusterDB.findByName(req.name);
91-
const clusterByUrlPromise = this.clusterDB.findFiltered({ url: req.url });
91+
const clusterByUrlPromise = this.clusterDB.findFiltered({
92+
url: req.url,
93+
applicationCluster: this.config.installation,
94+
});
9295

9396
const [clusterByName, clusterByUrl] = await Promise.all([clusterByNamePromise, clusterByUrlPromise]);
9497

@@ -303,7 +306,9 @@ export class ClusterService implements IClusterServiceServer {
303306
const response = new ListResponse();
304307

305308
const dbClusterIdx = new Map<string, boolean>();
306-
const allDBClusters = await this.clusterDB.findFiltered({});
309+
const allDBClusters = await this.clusterDB.findFiltered({
310+
applicationCluster: this.config.installation,
311+
});
307312
for (const cluster of allDBClusters) {
308313
const clusterStatus = convertToGRPC(cluster);
309314
response.addStatus(clusterStatus);

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ export class ClusterSyncService {
4848
}
4949

5050
log.debug("reconciling workspace classes...");
51-
let allClusters = await this.clusterDB.findFiltered({});
51+
let allClusters = await this.clusterDB.findFiltered({ applicationCluster: this.config.installation });
5252
for (const cluster of allClusters) {
5353
try {
5454
let supportedClasses = await getSupportedWorkspaceClasses(

0 commit comments

Comments
 (0)