From 8dbad3f8d842f5b650f46b09c1f062ab9b021679 Mon Sep 17 00:00:00 2001 From: "opensearch-trigger-bot[bot]" <98922864+opensearch-trigger-bot[bot]@users.noreply.github.com> Date: Wed, 16 Oct 2024 12:36:17 -0700 Subject: [PATCH] [MDS] Mute the non-mds endpoints for direct query data connections (#8537) (#8597) * Mute the non-mds endpoints for direct query data connections when MDS enabled * Handle the case for local cluster too * Handle the case for local cluster 2 * Changeset file for PR #8537 created/updated --------- (cherry picked from commit 47ae28bb0d37fc30a48b446737fe6ce374508095) Signed-off-by: Ryan Liang Signed-off-by: github-actions[bot] Co-authored-by: github-actions[bot] Co-authored-by: opensearch-changeset-bot[bot] <154024398+opensearch-changeset-bot[bot]@users.noreply.github.com> --- changelogs/fragments/8537.yml | 2 ++ .../data_source_management/public/components/utils.ts | 2 +- .../server/routes/data_connections_router.ts | 4 +++- src/plugins/data_source_management/server/routes/index.ts | 8 +++++++- 4 files changed, 13 insertions(+), 3 deletions(-) create mode 100644 changelogs/fragments/8537.yml diff --git a/changelogs/fragments/8537.yml b/changelogs/fragments/8537.yml new file mode 100644 index 000000000000..1afbb41a42e0 --- /dev/null +++ b/changelogs/fragments/8537.yml @@ -0,0 +1,2 @@ +fix: +- [MDS] Mute the non-mds endpoints for direct query data connections ([#8537](https://github.com/opensearch-project/OpenSearch-Dashboards/pull/8537)) \ No newline at end of file diff --git a/src/plugins/data_source_management/public/components/utils.ts b/src/plugins/data_source_management/public/components/utils.ts index c8b10eaddf91..8ec6c558e66f 100644 --- a/src/plugins/data_source_management/public/components/utils.ts +++ b/src/plugins/data_source_management/public/components/utils.ts @@ -62,7 +62,7 @@ export const getDirectQueryConnections = async (dataSourceId: string, http: Http }; export const getLocalClusterConnections = async (http: HttpSetup) => { - const res = await http.get(`${DATACONNECTIONS_BASE}`); + const res = await http.get(`${DATACONNECTIONS_BASE}/dataSourceMDSId=`); const localClusterConnections: DataSourceTableItem[] = res.map( (dataConnection: DirectQueryDatasourceDetails) => ({ id: `${dataConnection.name}`, diff --git a/src/plugins/data_source_management/server/routes/data_connections_router.ts b/src/plugins/data_source_management/server/routes/data_connections_router.ts index 6b8dc4b42054..4533e75c405b 100644 --- a/src/plugins/data_source_management/server/routes/data_connections_router.ts +++ b/src/plugins/data_source_management/server/routes/data_connections_router.ts @@ -16,7 +16,7 @@ import { EDIT, } from '../../framework/utils/shared'; -export function registerDataConnectionsRoute(router: IRouter, dataSourceEnabled: boolean) { +export function registerNonMdsDataConnectionsRoute(router: IRouter) { router.get( { path: `${DATACONNECTIONS_BASE}/{name}`, @@ -204,7 +204,9 @@ export function registerDataConnectionsRoute(router: IRouter, dataSourceEnabled: } } ); +} +export function registerDataConnectionsRoute(router: IRouter, dataSourceEnabled: boolean) { router.get( { path: `${DATACONNECTIONS_BASE}/dataSourceMDSId={dataSourceMDSId?}`, diff --git a/src/plugins/data_source_management/server/routes/index.ts b/src/plugins/data_source_management/server/routes/index.ts index 7fdca26b50ee..2bab16798262 100644 --- a/src/plugins/data_source_management/server/routes/index.ts +++ b/src/plugins/data_source_management/server/routes/index.ts @@ -5,7 +5,10 @@ import { IRouter, ILegacyClusterClient } from '../../../../core/server'; import { registerDslRoute } from './dsl'; -import { registerDataConnectionsRoute } from './data_connections_router'; +import { + registerDataConnectionsRoute, + registerNonMdsDataConnectionsRoute, +} from './data_connections_router'; import { registerDatasourcesRoute } from './datasources_router'; import { registerPplRoute } from './ppl'; import { DSLFacet } from '../services/facets/dsl_facet'; @@ -43,6 +46,9 @@ export function setupRoutes({ // const queryService = new QueryService(client); // registerSqlRoute(router, queryService); + if (!dataSourceEnabled) { + registerNonMdsDataConnectionsRoute(router); + } registerDataConnectionsRoute(router, dataSourceEnabled); registerDatasourcesRoute(router, dataSourceEnabled); }