Skip to content

Commit 732eff0

Browse files
authored
chore(indexes): add feature flag for rolling indexes COMPASS-8507 (#6509)
* chore(indexes): add feature flag for rolling indexes * chore: remove custom docker registry
1 parent 8512aa7 commit 732eff0

File tree

10 files changed

+52
-7
lines changed

10 files changed

+52
-7
lines changed

.evergreen/start-atlas-cloud-cluster.sh

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
RUN_ID="$(date +"%s")-$(git rev-parse --short HEAD)"
44
DELETE_AFTER="$(date -u -Iseconds -d '+2 hours' 2>/dev/null || date -u -Iseconds -v '+2H')"
5+
DOCKER_REGISTRY="${DOCKER_REGISTRY:-docker.io}"
56

67
# This script helps to automatically provision Atlas cluster for running the e2e
78
# tests against. In CI this will always create a new cluster and delete it when
@@ -39,8 +40,8 @@ DELETE_AFTER="$(date -u -Iseconds -d '+2 hours' 2>/dev/null || date -u -Iseconds
3940
# MCLI_ORG_ID Org ID
4041
# MCLI_PROJECT_ID Project ID
4142
#
42-
# COMPASS_E2E_ATLAS_CLOUD_SANDBOX_USERNAME Cloud user you created
43-
# COMPASS_E2E_ATLAS_CLOUD_SANDBOX_PASSWORD Cloud user password
43+
# COMPASS_E2E_ATLAS_CLOUD_SANDBOX_USERNAME Cloud user you created
44+
# COMPASS_E2E_ATLAS_CLOUD_SANDBOX_PASSWORD Cloud user password
4445
#
4546
# - Source the script followed by running the tests to make sure that some
4647
# variables exported from this script are available for the test env:
@@ -68,7 +69,7 @@ function atlascli() {
6869
-e MCLI_ORG_ID \
6970
-e MCLI_PROJECT_ID \
7071
-e MCLI_OPS_MANAGER_URL \
71-
mongodb/atlas atlas $@
72+
"$DOCKER_REGISTRY/mongodb/atlas" atlas $@
7273
}
7374

7475
cleanup() {

packages/compass-indexes/src/components/create-index-form/create-index-form.tsx

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import {
1010
useConnectionInfo,
1111
useConnectionSupports,
1212
} from '@mongodb-js/compass-connections/provider';
13+
import { usePreference } from 'compass-preferences-model/provider';
1314

1415
const createIndexModalFieldsStyles = css({
1516
margin: `${spacing[4]}px 0 ${spacing[5]}px 0`,
@@ -43,10 +44,13 @@ function CreateIndexForm({
4344
onRemoveFieldClick,
4445
}: CreateIndexFormProps) {
4546
const { id: connectionId } = useConnectionInfo();
47+
const rollingIndexesFeatureEnabled = !!usePreference('enableRollingIndexes');
4648
const supportsRollingIndexes = useConnectionSupports(
4749
connectionId,
4850
'rollingIndexCreation'
4951
);
52+
const showRollingIndexOption =
53+
rollingIndexesFeatureEnabled && supportsRollingIndexes;
5054
const schemaFields = useAutocompleteFields(namespace);
5155
const schemaFieldNames = useMemo(() => {
5256
return schemaFields
@@ -95,7 +99,7 @@ function CreateIndexForm({
9599
<CollapsibleInput name="columnstoreProjection"></CollapsibleInput>
96100
)}
97101
<CheckboxInput name="sparse"></CheckboxInput>
98-
{supportsRollingIndexes && (
102+
{showRollingIndexOption && (
99103
<CheckboxInput name="buildInRollingProcess"></CheckboxInput>
100104
)}
101105
</div>

packages/compass-indexes/src/index.spec.tsx

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,11 @@ describe('CompassIndexesPlugin', function () {
6060
instanceSize: 'VERY BIG',
6161
metricsType: 'replicaSet',
6262
} as any,
63+
},
64+
{
65+
preferences: {
66+
enableRollingIndexes: true,
67+
},
6368
}
6469
);
6570
}

packages/compass-indexes/src/index.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ import { createLoggerLocator } from '@mongodb-js/compass-logging/provider';
1818
import { telemetryLocator } from '@mongodb-js/compass-telemetry/provider';
1919
import { IndexesTabTitle } from './plugin-title';
2020
import { atlasServiceLocator } from '@mongodb-js/atlas-service/provider';
21+
import { preferencesLocator } from 'compass-preferences-model/provider';
2122

2223
export const CompassIndexesHadronPlugin = registerHadronPlugin(
2324
{
@@ -36,6 +37,7 @@ export const CompassIndexesHadronPlugin = registerHadronPlugin(
3637
track: telemetryLocator,
3738
collection: collectionModelLocator,
3839
atlasService: atlasServiceLocator,
40+
preferences: preferencesLocator,
3941
}
4042
);
4143

packages/compass-indexes/src/modules/index.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ import type { ConnectionInfoRef } from '@mongodb-js/compass-connections/provider
2020
import type { IndexesDataServiceProps } from '../stores/store';
2121
import type { Collection } from '@mongodb-js/compass-app-stores/provider';
2222
import type { RollingIndexesService } from './rolling-indexes-service';
23+
import type { PreferencesAccess } from 'compass-preferences-model';
2324
const reducer = combineReducers({
2425
// From instance.isWritable. Used to know if the create button should be
2526
// enabled.
@@ -76,6 +77,7 @@ export type IndexesExtraArgs = {
7677
regularIndexes: ReturnType<typeof setInterval> | null;
7778
searchIndexes: ReturnType<typeof setInterval> | null;
7879
};
80+
preferences: PreferencesAccess;
7981
};
8082
export type IndexesThunkDispatch<A extends Action = AnyAction> = ThunkDispatch<
8183
RootState,

packages/compass-indexes/src/modules/regular-indexes.ts

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -369,7 +369,13 @@ const fetchIndexes = (
369369
return async (
370370
dispatch,
371371
getState,
372-
{ dataService, collection, connectionInfoRef, rollingIndexesService }
372+
{
373+
dataService,
374+
collection,
375+
connectionInfoRef,
376+
rollingIndexesService,
377+
preferences,
378+
}
373379
) => {
374380
const {
375381
isReadonlyView,
@@ -387,16 +393,21 @@ const fetchIndexes = (
387393
return;
388394
}
389395

390-
const isRollingIndexesSupported = connectionSupports(
396+
const clusterSupportsRollingIndexes = connectionSupports(
391397
connectionInfoRef.current,
392398
'rollingIndexCreation'
393399
);
400+
const rollingIndexesEnabled =
401+
!!preferences.getPreferences().enableRollingIndexes;
402+
403+
const shouldFetchRollingIndexes =
404+
clusterSupportsRollingIndexes && rollingIndexesEnabled;
394405

395406
try {
396407
dispatch(fetchIndexesStarted(reason));
397408
const promises = [
398409
dataService.indexes(namespace),
399-
isRollingIndexesSupported
410+
shouldFetchRollingIndexes
400411
? rollingIndexesService.listRollingIndexes(namespace)
401412
: undefined,
402413
] as [Promise<IndexDefinition[]>, Promise<AtlasIndexStats[]> | undefined];

packages/compass-indexes/src/stores/store.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ import {
3232
} from '../modules/collection-stats';
3333
import type { AtlasService } from '@mongodb-js/atlas-service/provider';
3434
import { RollingIndexesService } from '../modules/rolling-indexes-service';
35+
import type { PreferencesAccess } from 'compass-preferences-model';
3536

3637
export type IndexesDataServiceProps =
3738
| 'indexes'
@@ -60,6 +61,7 @@ export type IndexesPluginServices = {
6061
collection: Collection;
6162
track: TrackFunction;
6263
atlasService: AtlasService;
64+
preferences: PreferencesAccess;
6365
};
6466

6567
export type IndexesPluginOptions = {
@@ -85,6 +87,7 @@ export function activateIndexesPlugin(
8587
dataService,
8688
collection: collectionModel,
8789
atlasService,
90+
preferences,
8891
}: IndexesPluginServices,
8992
{ on, cleanup, addCleanup }: ActivateHelpers
9093
) {
@@ -119,6 +122,7 @@ export function activateIndexesPlugin(
119122
connectionInfoRef
120123
),
121124
pollingIntervalRef,
125+
preferences,
122126
})
123127
)
124128
);

packages/compass-indexes/test/setup-store.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -160,6 +160,13 @@ export const setupStore = (
160160
collection: createMockCollection(),
161161
connectionInfoRef,
162162
atlasService,
163+
preferences: {
164+
getPreferences() {
165+
return {
166+
enableRollingIndexes: true,
167+
};
168+
},
169+
} as any,
163170
...services,
164171
},
165172
createActivateHelpers()

packages/compass-preferences-model/src/feature-flags.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ export type FeatureFlags = {
2020
enableRenameCollectionModal: boolean;
2121
enableQueryHistoryAutocomplete: boolean;
2222
enableProxySupport: boolean;
23+
enableRollingIndexes: boolean;
2324
};
2425

2526
export const featureFlags: Required<{
@@ -84,4 +85,11 @@ export const featureFlags: Required<{
8485
long: 'Allows users to specify proxy configuration for the entire Compass application.',
8586
},
8687
},
88+
89+
enableRollingIndexes: {
90+
stage: 'development',
91+
description: {
92+
short: 'Enable creating indexes with the rolling build in Atlas Cloud',
93+
},
94+
},
8795
};

packages/compass-web/sandbox/index.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,7 @@ const App = () => {
7676
atlasServiceBackendPreset: atlasServiceSandboxBackendVariant,
7777
enableCreatingNewConnections: !isAtlas,
7878
enableGlobalWrites: isAtlas,
79+
enableRollingIndexes: isAtlas,
7980
}}
8081
onTrack={sandboxTelemetry.track}
8182
onDebug={sandboxLogger.debug}

0 commit comments

Comments
 (0)