From ba22bc369255430282065e174a247bbb892fe2cc Mon Sep 17 00:00:00 2001 From: Sergey Petushkov Date: Mon, 18 Nov 2024 17:16:41 +0100 Subject: [PATCH 1/2] chore(indexes): add feature flag for rolling indexes --- .evergreen/functions.yml | 2 ++ .evergreen/start-atlas-cloud-cluster.sh | 7 ++++--- .../create-index-form/create-index-form.tsx | 6 +++++- packages/compass-indexes/src/index.spec.tsx | 5 +++++ packages/compass-indexes/src/index.ts | 2 ++ packages/compass-indexes/src/modules/index.ts | 2 ++ .../src/modules/regular-indexes.ts | 17 ++++++++++++++--- packages/compass-indexes/src/stores/store.ts | 4 ++++ packages/compass-indexes/test/setup-store.ts | 7 +++++++ .../src/feature-flags.ts | 8 ++++++++ packages/compass-web/sandbox/index.tsx | 1 + 11 files changed, 54 insertions(+), 7 deletions(-) diff --git a/.evergreen/functions.yml b/.evergreen/functions.yml index bb69785b943..792519140a5 100644 --- a/.evergreen/functions.yml +++ b/.evergreen/functions.yml @@ -690,6 +690,8 @@ functions: MCLI_ORG_ID: ${e2e_tests_mcli_org_id} MCLI_PROJECT_ID: ${e2e_tests_mcli_project_id} MCLI_OPS_MANAGER_URL: ${e2e_tests_mcli_ops_manager_url} + # TODO: remove when issues with docker are resolved + DOCKER_REGISTRY: artifactory.corp.mongodb.com/dockerhub script: | set -e # Load environment variables diff --git a/.evergreen/start-atlas-cloud-cluster.sh b/.evergreen/start-atlas-cloud-cluster.sh index 5c38b3d1f14..c4d59a41c8b 100644 --- a/.evergreen/start-atlas-cloud-cluster.sh +++ b/.evergreen/start-atlas-cloud-cluster.sh @@ -2,6 +2,7 @@ RUN_ID="$(date +"%s")-$(git rev-parse --short HEAD)" DELETE_AFTER="$(date -u -Iseconds -d '+2 hours' 2>/dev/null || date -u -Iseconds -v '+2H')" +DOCKER_REGISTRY="${DOCKER_REGISTRY:-docker.io}" # This script helps to automatically provision Atlas cluster for running the e2e # 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 # MCLI_ORG_ID Org ID # MCLI_PROJECT_ID Project ID # -# COMPASS_E2E_ATLAS_CLOUD_SANDBOX_USERNAME Cloud user you created -# COMPASS_E2E_ATLAS_CLOUD_SANDBOX_PASSWORD Cloud user password +# COMPASS_E2E_ATLAS_CLOUD_SANDBOX_USERNAME Cloud user you created +# COMPASS_E2E_ATLAS_CLOUD_SANDBOX_PASSWORD Cloud user password # # - Source the script followed by running the tests to make sure that some # variables exported from this script are available for the test env: @@ -68,7 +69,7 @@ function atlascli() { -e MCLI_ORG_ID \ -e MCLI_PROJECT_ID \ -e MCLI_OPS_MANAGER_URL \ - mongodb/atlas atlas $@ + "$DOCKER_REGISTRY/mongodb/atlas" atlas $@ } cleanup() { diff --git a/packages/compass-indexes/src/components/create-index-form/create-index-form.tsx b/packages/compass-indexes/src/components/create-index-form/create-index-form.tsx index 2cb7b37cde4..111f3442a12 100644 --- a/packages/compass-indexes/src/components/create-index-form/create-index-form.tsx +++ b/packages/compass-indexes/src/components/create-index-form/create-index-form.tsx @@ -10,6 +10,7 @@ import { useConnectionInfo, useConnectionSupports, } from '@mongodb-js/compass-connections/provider'; +import { usePreference } from 'compass-preferences-model/provider'; const createIndexModalFieldsStyles = css({ margin: `${spacing[4]}px 0 ${spacing[5]}px 0`, @@ -43,10 +44,13 @@ function CreateIndexForm({ onRemoveFieldClick, }: CreateIndexFormProps) { const { id: connectionId } = useConnectionInfo(); + const rollingIndexesFeatureEnabled = !!usePreference('enableRollingIndexes'); const supportsRollingIndexes = useConnectionSupports( connectionId, 'rollingIndexCreation' ); + const showRollingIndexOption = + rollingIndexesFeatureEnabled && supportsRollingIndexes; const schemaFields = useAutocompleteFields(namespace); const schemaFieldNames = useMemo(() => { return schemaFields @@ -95,7 +99,7 @@ function CreateIndexForm({ )} - {supportsRollingIndexes && ( + {showRollingIndexOption && ( )} diff --git a/packages/compass-indexes/src/index.spec.tsx b/packages/compass-indexes/src/index.spec.tsx index 735a7657e4f..c03f1e1155f 100644 --- a/packages/compass-indexes/src/index.spec.tsx +++ b/packages/compass-indexes/src/index.spec.tsx @@ -60,6 +60,11 @@ describe('CompassIndexesPlugin', function () { instanceSize: 'VERY BIG', metricsType: 'replicaSet', } as any, + }, + { + preferences: { + enableRollingIndexes: true, + }, } ); } diff --git a/packages/compass-indexes/src/index.ts b/packages/compass-indexes/src/index.ts index 6076784fcc1..618264908c1 100644 --- a/packages/compass-indexes/src/index.ts +++ b/packages/compass-indexes/src/index.ts @@ -18,6 +18,7 @@ import { createLoggerLocator } from '@mongodb-js/compass-logging/provider'; import { telemetryLocator } from '@mongodb-js/compass-telemetry/provider'; import { IndexesTabTitle } from './plugin-title'; import { atlasServiceLocator } from '@mongodb-js/atlas-service/provider'; +import { preferencesLocator } from 'compass-preferences-model/provider'; export const CompassIndexesHadronPlugin = registerHadronPlugin( { @@ -36,6 +37,7 @@ export const CompassIndexesHadronPlugin = registerHadronPlugin( track: telemetryLocator, collection: collectionModelLocator, atlasService: atlasServiceLocator, + preferences: preferencesLocator, } ); diff --git a/packages/compass-indexes/src/modules/index.ts b/packages/compass-indexes/src/modules/index.ts index cc74f417111..079984a1473 100644 --- a/packages/compass-indexes/src/modules/index.ts +++ b/packages/compass-indexes/src/modules/index.ts @@ -20,6 +20,7 @@ import type { ConnectionInfoRef } from '@mongodb-js/compass-connections/provider import type { IndexesDataServiceProps } from '../stores/store'; import type { Collection } from '@mongodb-js/compass-app-stores/provider'; import type { RollingIndexesService } from './rolling-indexes-service'; +import type { PreferencesAccess } from 'compass-preferences-model'; const reducer = combineReducers({ // From instance.isWritable. Used to know if the create button should be // enabled. @@ -76,6 +77,7 @@ export type IndexesExtraArgs = { regularIndexes: ReturnType | null; searchIndexes: ReturnType | null; }; + preferences: PreferencesAccess; }; export type IndexesThunkDispatch = ThunkDispatch< RootState, diff --git a/packages/compass-indexes/src/modules/regular-indexes.ts b/packages/compass-indexes/src/modules/regular-indexes.ts index 8efe1c0af90..dbc86071170 100644 --- a/packages/compass-indexes/src/modules/regular-indexes.ts +++ b/packages/compass-indexes/src/modules/regular-indexes.ts @@ -369,7 +369,13 @@ const fetchIndexes = ( return async ( dispatch, getState, - { dataService, collection, connectionInfoRef, rollingIndexesService } + { + dataService, + collection, + connectionInfoRef, + rollingIndexesService, + preferences, + } ) => { const { isReadonlyView, @@ -387,16 +393,21 @@ const fetchIndexes = ( return; } - const isRollingIndexesSupported = connectionSupports( + const clusterSupportsRollingIndexes = connectionSupports( connectionInfoRef.current, 'rollingIndexCreation' ); + const rollingIndexesEnabled = + !!preferences.getPreferences().enableRollingIndexes; + + const shouldFetchRollingIndexes = + clusterSupportsRollingIndexes && rollingIndexesEnabled; try { dispatch(fetchIndexesStarted(reason)); const promises = [ dataService.indexes(namespace), - isRollingIndexesSupported + shouldFetchRollingIndexes ? rollingIndexesService.listRollingIndexes(namespace) : undefined, ] as [Promise, Promise | undefined]; diff --git a/packages/compass-indexes/src/stores/store.ts b/packages/compass-indexes/src/stores/store.ts index e6c56c7c778..ad9cde454e7 100644 --- a/packages/compass-indexes/src/stores/store.ts +++ b/packages/compass-indexes/src/stores/store.ts @@ -32,6 +32,7 @@ import { } from '../modules/collection-stats'; import type { AtlasService } from '@mongodb-js/atlas-service/provider'; import { RollingIndexesService } from '../modules/rolling-indexes-service'; +import type { PreferencesAccess } from 'compass-preferences-model'; export type IndexesDataServiceProps = | 'indexes' @@ -60,6 +61,7 @@ export type IndexesPluginServices = { collection: Collection; track: TrackFunction; atlasService: AtlasService; + preferences: PreferencesAccess; }; export type IndexesPluginOptions = { @@ -85,6 +87,7 @@ export function activateIndexesPlugin( dataService, collection: collectionModel, atlasService, + preferences, }: IndexesPluginServices, { on, cleanup, addCleanup }: ActivateHelpers ) { @@ -119,6 +122,7 @@ export function activateIndexesPlugin( connectionInfoRef ), pollingIntervalRef, + preferences, }) ) ); diff --git a/packages/compass-indexes/test/setup-store.ts b/packages/compass-indexes/test/setup-store.ts index 2b8a7676ece..32ee2231143 100644 --- a/packages/compass-indexes/test/setup-store.ts +++ b/packages/compass-indexes/test/setup-store.ts @@ -160,6 +160,13 @@ export const setupStore = ( collection: createMockCollection(), connectionInfoRef, atlasService, + preferences: { + getPreferences() { + return { + enableRollingIndexes: true, + }; + }, + } as any, ...services, }, createActivateHelpers() diff --git a/packages/compass-preferences-model/src/feature-flags.ts b/packages/compass-preferences-model/src/feature-flags.ts index 58a2774d09b..85b12aca7e3 100644 --- a/packages/compass-preferences-model/src/feature-flags.ts +++ b/packages/compass-preferences-model/src/feature-flags.ts @@ -20,6 +20,7 @@ export type FeatureFlags = { enableRenameCollectionModal: boolean; enableQueryHistoryAutocomplete: boolean; enableProxySupport: boolean; + enableRollingIndexes: boolean; }; export const featureFlags: Required<{ @@ -84,4 +85,11 @@ export const featureFlags: Required<{ long: 'Allows users to specify proxy configuration for the entire Compass application.', }, }, + + enableRollingIndexes: { + stage: 'development', + description: { + short: 'Enable creating indexes with the rolling build in Atlas Cloud', + }, + }, }; diff --git a/packages/compass-web/sandbox/index.tsx b/packages/compass-web/sandbox/index.tsx index a481158c4dc..9404f893c3c 100644 --- a/packages/compass-web/sandbox/index.tsx +++ b/packages/compass-web/sandbox/index.tsx @@ -76,6 +76,7 @@ const App = () => { atlasServiceBackendPreset: atlasServiceSandboxBackendVariant, enableCreatingNewConnections: !isAtlas, enableGlobalWrites: isAtlas, + enableRollingIndexes: isAtlas, }} onTrack={sandboxTelemetry.track} onDebug={sandboxLogger.debug} From a2e0b7536db2ffdbd623db6f7a83734ea49e90c8 Mon Sep 17 00:00:00 2001 From: Sergey Petushkov Date: Tue, 19 Nov 2024 09:21:32 +0100 Subject: [PATCH 2/2] chore: remove custom docker registry --- .evergreen/functions.yml | 2 -- 1 file changed, 2 deletions(-) diff --git a/.evergreen/functions.yml b/.evergreen/functions.yml index 792519140a5..bb69785b943 100644 --- a/.evergreen/functions.yml +++ b/.evergreen/functions.yml @@ -690,8 +690,6 @@ functions: MCLI_ORG_ID: ${e2e_tests_mcli_org_id} MCLI_PROJECT_ID: ${e2e_tests_mcli_project_id} MCLI_OPS_MANAGER_URL: ${e2e_tests_mcli_ops_manager_url} - # TODO: remove when issues with docker are resolved - DOCKER_REGISTRY: artifactory.corp.mongodb.com/dockerhub script: | set -e # Load environment variables