Skip to content

Commit 9fec0b0

Browse files
authored
fix: avoid global writes for self managed sharding COMPASS-8579 (#6535)
* fix: avoid global writes for self managed sharding COMPASS_8579 * test: add tests
1 parent 0fdb9d1 commit 9fec0b0

File tree

5 files changed

+53
-1
lines changed

5 files changed

+53
-1
lines changed

packages/compass-connections/src/utils/connection-supports.spec.ts

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,9 @@ const mockConnections: ConnectionInfo[] = [
9292
instanceSize: 'M10',
9393
clusterType: 'SHARDED',
9494
clusterUniqueId: 'clusterUniqueId',
95+
geoSharding: {
96+
selfManagedSharding: false,
97+
},
9598
},
9699
},
97100
{
@@ -111,6 +114,26 @@ const mockConnections: ConnectionInfo[] = [
111114
clusterUniqueId: 'clusterUniqueId',
112115
},
113116
},
117+
{
118+
id: 'dedicated-geo-sharded-self-managed',
119+
connectionOptions: {
120+
connectionString: 'mongodb://foo',
121+
},
122+
atlasMetadata: {
123+
orgId: 'orgId',
124+
projectId: 'projectId',
125+
clusterName: 'clusterName',
126+
regionalBaseUrl: 'https://example.com',
127+
metricsId: 'metricsId',
128+
metricsType: 'cluster',
129+
instanceSize: 'M30',
130+
clusterType: 'GEOSHARDED',
131+
clusterUniqueId: 'clusterUniqueId',
132+
geoSharding: {
133+
selfManagedSharding: true,
134+
},
135+
},
136+
},
114137
];
115138

116139
function connectionInfoById(connectionId: string): ConnectionInfo {
@@ -195,5 +218,14 @@ describe('connectionSupports', function () {
195218
)
196219
).to.be.true;
197220
});
221+
222+
it('should return false if the cluster type is geosharded but self managed', function () {
223+
expect(
224+
connectionSupports(
225+
connectionInfoById('dedicated-geo-sharded-self-managed'),
226+
'globalWrites'
227+
)
228+
).to.be.false;
229+
});
198230
});
199231
});

packages/compass-connections/src/utils/connection-supports.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,10 @@ function supportsGlobalWrites(connectionInfo: ConnectionInfo) {
3030
return false;
3131
}
3232

33-
return atlasMetadata.clusterType === 'GEOSHARDED';
33+
return (
34+
atlasMetadata.clusterType === 'GEOSHARDED' &&
35+
!atlasMetadata.geoSharding?.selfManagedSharding
36+
);
3437
}
3538

3639
export function connectionSupports(

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

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,9 @@ describe('buildConnectionInfoFromClusterDescription', function () {
6868
dataProcessingRegion: {
6969
regionalUrl: 'https://example.com',
7070
},
71+
geoSharding: {
72+
selfManagedSharding: true,
73+
},
7174
replicationSpecList: [
7275
{
7376
regionConfigs: [
@@ -162,6 +165,10 @@ describe('buildConnectionInfoFromClusterDescription', function () {
162165
instanceSize: expectedInstanceSize,
163166
regionalBaseUrl: 'https://example.com',
164167
clusterType: clusterDescription.clusterType,
168+
geoSharding: {
169+
selfManagedSharding:
170+
clusterDescription.geoSharding?.selfManagedSharding,
171+
},
165172
});
166173
});
167174
}

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

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,9 @@ type ClusterDescription = {
3838
deploymentItemName: string;
3939
replicationSpecList?: ReplicationSpec[];
4040
isPaused?: boolean;
41+
geoSharding?: {
42+
selfManagedSharding?: boolean;
43+
};
4144
};
4245

4346
export type ClusterDescriptionWithDataProcessingRegion = ClusterDescription & {
@@ -205,6 +208,9 @@ export function buildConnectionInfoFromClusterDescription(
205208
...getMetricsIdAndType(description, deploymentItem),
206209
instanceSize: getInstanceSize(description),
207210
clusterType: description.clusterType,
211+
geoSharding: {
212+
selfManagedSharding: description.geoSharding?.selfManagedSharding,
213+
},
208214
},
209215
};
210216
}

packages/connection-info/src/connection-info.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,10 @@ export interface AtlasClusterMetadata {
5656
* https://github.com/10gen/mms/blob/9e6bf2d81d4d85b5ac68a15bf471dcddc5922323/client/packages/types/nds/clusterDescription.ts#L12-L16
5757
*/
5858
clusterType: 'REPLICASET' | 'SHARDED' | 'GEOSHARDED';
59+
60+
geoSharding?: {
61+
selfManagedSharding?: boolean;
62+
};
5963
}
6064

6165
export interface ConnectionInfo {

0 commit comments

Comments
 (0)