Skip to content

Commit d11e196

Browse files
authored
fix: fix terminated cluster states COMPASS-9367 (#6945)
* fix terminated cluster states
1 parent 0fdb2e4 commit d11e196

File tree

2 files changed

+8
-13
lines changed

2 files changed

+8
-13
lines changed

packages/compass-web/src/connection-storage.spec.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,10 @@ describe('buildConnectionInfoFromClusterDescription', function () {
166166
deployment
167167
);
168168

169-
expect(connectionInfo).to.have.property('id', clusterDescription.name);
169+
expect(connectionInfo).to.have.property(
170+
'id',
171+
clusterDescription.uniqueId
172+
);
170173

171174
expect(connectionInfo).to.have.nested.property(
172175
'connectionOptions.connectionString',

packages/compass-web/src/connection-storage.tsx

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -207,10 +207,7 @@ export function buildConnectionInfoFromClusterDescription(
207207
const instanceSize = getInstanceSize(description);
208208

209209
return {
210-
// Cluster name is unique inside the project (hence using it in the backend
211-
// urls as identifier) and using it as an id makes our job of mapping routes
212-
// to compass state easier
213-
id: description.name,
210+
id: description.uniqueId,
214211
connectionOptions: {
215212
connectionString: connectionString.toString(),
216213
lookup: () => {
@@ -265,7 +262,7 @@ export class AtlasCloudConnectionStorage
265262
implements ConnectionStorage
266263
{
267264
private loadAllPromise: Promise<ConnectionInfo[]> | undefined;
268-
private canUseNewConnectionInfoEndpoint = true;
265+
private useNewConnectionInfoEndpoint = true;
269266
constructor(
270267
private atlasService: AtlasService,
271268
private orgId: string,
@@ -420,15 +417,10 @@ export class AtlasCloudConnectionStorage
420417

421418
loadAll(): Promise<ConnectionInfo[]> {
422419
this.loadAllPromise ??= (async () => {
423-
if (this.canUseNewConnectionInfoEndpoint === false) {
424-
return this._loadAndNormalizeClusterDescriptionInfoV1();
425-
}
426-
try {
427-
return await this._loadAndNormalizeClusterDescriptionInfoV2();
428-
} catch (err) {
429-
this.canUseNewConnectionInfoEndpoint = false;
420+
if (this.useNewConnectionInfoEndpoint === false) {
430421
return this._loadAndNormalizeClusterDescriptionInfoV1();
431422
}
423+
return await this._loadAndNormalizeClusterDescriptionInfoV2();
432424
})().finally(() => {
433425
delete this.loadAllPromise;
434426
});

0 commit comments

Comments
 (0)