Skip to content

Commit 0e2ec6c

Browse files
authored
Remove usage of applicationCluster column from WorkspaceCluster (#16824)
* Remove usage of applicationCluster column from WorkspaceCluster * fix * Fix * fix * Fix * fix * Fix * fix * Fix * Fix * fix
1 parent e9fcb45 commit 0e2ec6c

File tree

16 files changed

+74
-212
lines changed

16 files changed

+74
-212
lines changed

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

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -88,12 +88,6 @@ export class DBWorkspaceCluster implements WorkspaceCluster {
8888
})
8989
admissionConstraints?: AdmissionConstraint[];
9090

91-
@Column({
92-
type: "varchar",
93-
length: 60,
94-
})
95-
applicationCluster: string;
96-
9791
@Column({
9892
type: "varchar",
9993
length: 60,

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

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -32,14 +32,14 @@ export class WorkspaceClusterDBImpl implements WorkspaceClusterDB {
3232
await repo.save(cluster);
3333
}
3434

35-
async deleteByName(name: string, applicationCluster: string): Promise<void> {
35+
async deleteByName(name: string): Promise<void> {
3636
const repo = await this.getRepo();
37-
await repo.update({ name, applicationCluster }, { deleted: true });
37+
await repo.update({ name }, { deleted: true });
3838
}
3939

40-
async findByName(name: string, applicationCluster: string): Promise<WorkspaceCluster | undefined> {
40+
async findByName(name: string): Promise<WorkspaceCluster | undefined> {
4141
const repo = await this.getRepo();
42-
return repo.findOne({ name, applicationCluster, deleted: false });
42+
return repo.findOne({ name, deleted: false });
4343
}
4444

4545
async findFiltered(predicate: WorkspaceClusterFilter): Promise<WorkspaceClusterWoTLS[]> {
@@ -52,7 +52,6 @@ export class WorkspaceClusterDBImpl implements WorkspaceClusterDB {
5252
state: "available",
5353
govern: false,
5454
admissionConstraints: [],
55-
applicationCluster: "",
5655
};
5756

5857
const repo = await this.getRepo();
@@ -63,9 +62,6 @@ export class WorkspaceClusterDBImpl implements WorkspaceClusterDB {
6362
if (predicate.name !== undefined) {
6463
qb = qb.andWhere("wsc.name = :name", predicate);
6564
}
66-
if (predicate.applicationCluster !== undefined) {
67-
qb = qb.andWhere("wsc.applicationCluster = :applicationCluster", predicate);
68-
}
6965
if (predicate.state !== undefined) {
7066
qb = qb.andWhere("wsc.state = :state", predicate);
7167
}

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

Lines changed: 11 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,6 @@ export class WorkspaceClusterDBSpec {
3535
@test public async findByName() {
3636
const wsc1: DBWorkspaceCluster = dbWorkspaceCluster({
3737
name: "eu71",
38-
applicationCluster: "us02",
3938
region: "europe",
4039
url: "some-url",
4140
state: "available",
@@ -45,7 +44,6 @@ export class WorkspaceClusterDBSpec {
4544
});
4645
const wsc2: DBWorkspaceCluster = dbWorkspaceCluster({
4746
name: "us71",
48-
applicationCluster: "us02",
4947
region: "europe",
5048
url: "some-url",
5149
state: "cordoned",
@@ -57,42 +55,28 @@ export class WorkspaceClusterDBSpec {
5755
await this.db.save(wsc1);
5856
await this.db.save(wsc2);
5957

60-
const result = await this.db.findByName("eu71", "us02");
58+
const result = await this.db.findByName("eu71");
6159
expect(result).not.to.be.undefined;
6260
expect((result as WorkspaceCluster).name).to.equal("eu71");
63-
expect((result as WorkspaceCluster).applicationCluster).to.equal("us02");
6461

6562
// Can find the eu71 cluster as seen by the us02 application cluster.
66-
const result2 = await this.db.findByName("eu71", "us02");
63+
const result2 = await this.db.findByName("eu71");
6764
expect(result2).not.to.be.undefined;
6865
expect((result2 as WorkspaceCluster).name).to.equal("eu71");
69-
expect((result2 as WorkspaceCluster).applicationCluster).to.equal("us02");
7066
}
7167

7268
@test public async deleteByName() {
7369
const wsc1: DBWorkspaceCluster = dbWorkspaceCluster({
7470
name: "eu71",
75-
applicationCluster: "eu02",
7671
region: "europe",
7772
url: "some-url",
7873
state: "available",
7974
score: 100,
8075
maxScore: 100,
8176
govern: true,
8277
});
83-
const wsc1a: DBWorkspaceCluster = dbWorkspaceCluster({
84-
name: "eu71",
85-
applicationCluster: "us02",
86-
region: "north-america",
87-
url: "some-url",
88-
state: "cordoned",
89-
score: 0,
90-
maxScore: 0,
91-
govern: false,
92-
});
9378
const wsc2: DBWorkspaceCluster = dbWorkspaceCluster({
9479
name: "us71",
95-
applicationCluster: "eu02",
9680
region: "europe",
9781
url: "some-url",
9882
state: "cordoned",
@@ -102,20 +86,16 @@ export class WorkspaceClusterDBSpec {
10286
});
10387

10488
await this.db.save(wsc1);
105-
await this.db.save(wsc1a);
10689
await this.db.save(wsc2);
10790

108-
// Can delete the eu71 cluster as seen by the eu02 application cluster.
109-
await this.db.deleteByName("eu71", "eu02");
110-
expect(await this.db.findByName("eu71", "eu02")).to.be.undefined;
111-
expect(await this.db.findByName("eu71", "us02")).not.to.be.undefined;
112-
expect(await this.db.findByName("us71", "eu02")).not.to.be.undefined;
91+
await this.db.deleteByName("eu71");
92+
expect(await this.db.findByName("eu71")).to.be.undefined;
93+
expect(await this.db.findByName("us71")).not.to.be.undefined;
11394
}
11495

11596
@test public async testFindFilteredByName() {
11697
const wsc1: DBWorkspaceCluster = dbWorkspaceCluster({
11798
name: "eu71",
118-
applicationCluster: "us02",
11999
region: "north-america",
120100
url: "some-url",
121101
state: "cordoned",
@@ -125,7 +105,6 @@ export class WorkspaceClusterDBSpec {
125105
});
126106
const wsc2: DBWorkspaceCluster = dbWorkspaceCluster({
127107
name: "us71",
128-
applicationCluster: "eu02",
129108
region: "europe",
130109
url: "some-url",
131110
state: "cordoned",
@@ -137,16 +116,14 @@ export class WorkspaceClusterDBSpec {
137116
await this.db.save(wsc1);
138117
await this.db.save(wsc2);
139118

140-
const wscs = await this.db.findFiltered({ name: "eu71", applicationCluster: "us02" });
119+
const wscs = await this.db.findFiltered({ name: "eu71" });
141120
expect(wscs.length).to.equal(1);
142121
expect(wscs[0].name).to.equal("eu71");
143-
expect(wscs[0].applicationCluster).to.equal("us02");
144122
}
145123

146124
@test public async testFindFilteredByApplicationCluster() {
147125
const wsc1: DBWorkspaceCluster = dbWorkspaceCluster({
148126
name: "eu71",
149-
applicationCluster: "us02",
150127
region: "europe",
151128
url: "some-url",
152129
state: "available",
@@ -157,7 +134,6 @@ export class WorkspaceClusterDBSpec {
157134
});
158135
const wsc2: DBWorkspaceCluster = dbWorkspaceCluster({
159136
name: "us71",
160-
applicationCluster: "us02",
161137
region: "north-america",
162138
url: "some-url",
163139
state: "available",
@@ -170,14 +146,13 @@ export class WorkspaceClusterDBSpec {
170146
await this.db.save(wsc1);
171147
await this.db.save(wsc2);
172148

173-
const wscs2 = await this.db.findFiltered({ applicationCluster: "us02" });
149+
const wscs2 = await this.db.findFiltered({});
174150
expect(wscs2.length).to.equal(2);
175151
}
176152

177153
@test public async testFindFilteredExcludesDeletedClusters() {
178154
const wsc1: DBWorkspaceCluster = dbWorkspaceCluster({
179155
name: "eu71",
180-
applicationCluster: "us02",
181156
region: "europe",
182157
url: "some-url",
183158
state: "available",
@@ -187,7 +162,6 @@ export class WorkspaceClusterDBSpec {
187162
});
188163
const wsc2: DBWorkspaceCluster = dbWorkspaceCluster({
189164
name: "us71",
190-
applicationCluster: "us02",
191165
region: "north-america",
192166
url: "some-url",
193167
state: "available",
@@ -199,17 +173,16 @@ export class WorkspaceClusterDBSpec {
199173
await this.db.save(wsc1);
200174
await this.db.save(wsc2);
201175

202-
await this.db.deleteByName("eu71", "us02");
176+
await this.db.deleteByName("eu71");
203177

204-
let wscs = await this.db.findFiltered({ applicationCluster: "us02" });
178+
let wscs = await this.db.findFiltered({});
205179
expect(wscs.length).to.equal(1);
206180
}
207181

208182
@test public async testFindFilteredWithRegion() {
209183
const clusters: DBWorkspaceCluster[] = [
210184
dbWorkspaceCluster({
211185
name: "eu71",
212-
applicationCluster: "eu02",
213186
region: "europe",
214187
url: "some-url",
215188
state: "available",
@@ -219,7 +192,6 @@ export class WorkspaceClusterDBSpec {
219192
}),
220193
dbWorkspaceCluster({
221194
name: "eu72",
222-
applicationCluster: "eu02",
223195
region: "",
224196
url: "some-url",
225197
state: "cordoned",
@@ -229,7 +201,6 @@ export class WorkspaceClusterDBSpec {
229201
}),
230202
dbWorkspaceCluster({
231203
name: "us71",
232-
applicationCluster: "eu02",
233204
region: "",
234205
url: "some-url",
235206
state: "available",
@@ -243,10 +214,10 @@ export class WorkspaceClusterDBSpec {
243214
await this.db.save(cluster);
244215
}
245216

246-
const withoutRegionFilter = await this.db.findFiltered({ applicationCluster: "eu02" });
217+
const withoutRegionFilter = await this.db.findFiltered({});
247218
expect(withoutRegionFilter.length).to.equal(3);
248219

249-
const matchingEurope = await this.db.findFiltered({ applicationCluster: "eu02", region: "europe" });
220+
const matchingEurope = await this.db.findFiltered({ region: "europe" });
250221
expect(matchingEurope.length).to.equal(1);
251222
}
252223
}

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

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,6 @@ export interface WorkspaceCluster {
2222
// Must be identical to the installationShortname of the cluster it represents!
2323
name: string;
2424

25-
// The name of the application cluster to which this cluster should be registered.
26-
// The name can be at most 60 characters.
27-
applicationCluster: string;
28-
2925
// The name of the region this cluster belongs to. E.g. europe or north-america
3026
// The name can be at most 60 characters.
3127
region: WorkspaceRegion;
@@ -101,13 +97,13 @@ export interface WorkspaceClusterDB {
10197
* Deletes the cluster identified by this name, if any.
10298
* @param name
10399
*/
104-
deleteByName(name: string, applicationCluster: string): Promise<void>;
100+
deleteByName(name: string): Promise<void>;
105101

106102
/**
107103
* Finds a WorkspaceCluster with the given name. If there is none, `undefined` is returned.
108104
* @param name
109105
*/
110-
findByName(name: string, applicationCluster: string): Promise<WorkspaceCluster | undefined>;
106+
findByName(name: string): Promise<WorkspaceCluster | undefined>;
111107

112108
/**
113109
* Lists all WorkspaceClusterWoTls for which the given predicate is true (does not return TLS for size/speed concerns)
@@ -116,6 +112,7 @@ export interface WorkspaceClusterDB {
116112
findFiltered(predicate: WorkspaceClusterFilter): Promise<WorkspaceClusterWoTLS[]>;
117113
}
118114

119-
export type WorkspaceClusterFilter = Pick<WorkspaceCluster, "applicationCluster"> &
120-
DeepPartial<Pick<WorkspaceCluster, "name" | "state" | "govern" | "url" | "region">> &
115+
export type WorkspaceClusterFilter = DeepPartial<
116+
Pick<WorkspaceCluster, "name" | "state" | "govern" | "url" | "region">
117+
> &
121118
Partial<{ minScore: number }>;

components/image-builder-api/typescript/src/sugar.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@ export const ImageBuilderClientProvider = Symbol("ImageBuilderClientProvider");
3232
// ImageBuilderClientProvider caches image builder connections
3333
export interface ImageBuilderClientProvider {
3434
getClient(
35-
applicationCluster: string,
3635
user: User,
3736
workspace: Workspace,
3837
instance?: WorkspaceInstance,
@@ -97,7 +96,7 @@ export class CachingImageBuilderClientProvider implements ImageBuilderClientProv
9796
return connection;
9897
}
9998

100-
async getClient(applicationCluster: string, user: User, workspace: Workspace, instance?: WorkspaceInstance) {
99+
async getClient(user: User, workspace: Workspace, instance?: WorkspaceInstance) {
101100
return this.getDefault();
102101
}
103102

components/server/ee/src/workspace/gitpod-server-impl.ts

Lines changed: 4 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -431,10 +431,7 @@ export class GitpodServerEEImpl extends GitpodServerImpl {
431431
}
432432
await this.guardAccess({ kind: "workspaceInstance", subject: runningInstance, workspace: workspace }, "update");
433433

434-
const client = await this.workspaceManagerClientProvider.get(
435-
runningInstance.region,
436-
this.config.installationShortname,
437-
);
434+
const client = await this.workspaceManagerClientProvider.get(runningInstance.region);
438435

439436
const req = new SetTimeoutRequest();
440437
req.setId(runningInstance.id);
@@ -470,10 +467,7 @@ export class GitpodServerEEImpl extends GitpodServerImpl {
470467
const req = new DescribeWorkspaceRequest();
471468
req.setId(runningInstance.id);
472469

473-
const client = await this.workspaceManagerClientProvider.get(
474-
runningInstance.region,
475-
this.config.installationShortname,
476-
);
470+
const client = await this.workspaceManagerClientProvider.get(runningInstance.region);
477471
const desc = await client.describeWorkspace(ctx, req);
478472
const duration = desc.getStatus()!.getSpec()!.getTimeout();
479473

@@ -520,10 +514,7 @@ export class GitpodServerEEImpl extends GitpodServerImpl {
520514
req.setId(instance.id);
521515
req.setLevel(lvlmap.get(level)!);
522516

523-
const client = await this.workspaceManagerClientProvider.get(
524-
instance.region,
525-
this.config.installationShortname,
526-
);
517+
const client = await this.workspaceManagerClientProvider.get(instance.region);
527518
await client.controlAdmission(ctx, req);
528519
}
529520

@@ -549,10 +540,7 @@ export class GitpodServerEEImpl extends GitpodServerImpl {
549540
}
550541
await this.guardAccess({ kind: "workspaceInstance", subject: instance, workspace }, "get");
551542

552-
const client = await this.workspaceManagerClientProvider.get(
553-
instance.region,
554-
this.config.installationShortname,
555-
);
543+
const client = await this.workspaceManagerClientProvider.get(instance.region);
556544
const request = new TakeSnapshotRequest();
557545
request.setId(instance.id);
558546
request.setReturnImmediately(true);

components/server/src/user/user-deletion-service.ts

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -122,10 +122,7 @@ export class UserDeletionService {
122122
req.setPolicy(StopWorkspacePolicy.NORMALLY);
123123

124124
try {
125-
const manager = await this.workspaceManagerClientProvider.get(
126-
wsi.region,
127-
this.config.installationShortname,
128-
);
125+
const manager = await this.workspaceManagerClientProvider.get(wsi.region);
129126
await manager.stopWorkspace({}, req);
130127
} catch (err) {
131128
log.debug(

0 commit comments

Comments
 (0)