Skip to content

Commit 7e6cdfd

Browse files
MDS Version Decoupling (opensearch-project#806)
* update snapshot Signed-off-by: Jackie Han <jkhanjob@gmail.com> * DMS version decoupling Signed-off-by: Jackie Han <jkhanjob@gmail.com> * update AD supported version range for mds version decoupling Signed-off-by: Jackie Han <jkhanjob@gmail.com> --------- Signed-off-by: Jackie Han <jkhanjob@gmail.com>
1 parent 89b6056 commit 7e6cdfd

File tree

12 files changed

+74
-3
lines changed

12 files changed

+74
-3
lines changed

opensearch_dashboards.json

+3-1
Original file line numberDiff line numberDiff line change
@@ -20,5 +20,7 @@
2020
"opensearchDashboardsUtils"
2121
],
2222
"server": true,
23-
"ui": true
23+
"ui": true,
24+
"supportedOSDataSourceVersions": ">=2.9.0",
25+
"requiredOSDataSourcePlugins": ["opensearch-anomaly-detection"]
2426
}

public/pages/ConfigureModel/containers/ConfigureModel.tsx

+2
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@ import { getErrorMessage } from '../../../utils/utils';
6161
import {
6262
constructHrefWithDataSourceId,
6363
getDataSourceFromURL,
64+
isDataSourceCompatible,
6465
} from '../../../pages/utils/helpers';
6566
import {
6667
getDataSourceManagementPlugin,
@@ -270,6 +271,7 @@ export function ConfigureModel(props: ConfigureModelProps) {
270271
fullWidth: false,
271272
savedObjects: getSavedObjectsClient(),
272273
notifications: getNotifications(),
274+
dataSourceFilter: isDataSourceCompatible,
273275
}}
274276
/>
275277
);

public/pages/Dashboard/Container/DashboardOverview.tsx

+2
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ import {
4343
getAllDetectorsQueryParamsWithDataSourceId,
4444
getDataSourceFromURL,
4545
getVisibleOptions,
46+
isDataSourceCompatible,
4647
} from '../../utils/helpers';
4748
import { BREADCRUMBS, MDS_BREADCRUMBS } from '../../../utils/constants';
4849
import { DETECTOR_STATE } from '../../../../server/utils/constants';
@@ -285,6 +286,7 @@ export function DashboardOverview(props: OverviewProps) {
285286
notifications: getNotifications(),
286287
onSelectedDataSources: (dataSources) =>
287288
handleDataSourceChange(dataSources),
289+
dataSourceFilter: isDataSourceCompatible,
288290
}}
289291
/>
290292
);

public/pages/DefineDetector/containers/DefineDetector.tsx

+3
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@ import { DataSourceSelectableConfig, DataSourceViewConfig } from '../../../../..
6666
import {
6767
constructHrefWithDataSourceId,
6868
getDataSourceFromURL,
69+
isDataSourceCompatible,
6970
} from '../../../pages/utils/helpers';
7071
import queryString from 'querystring';
7172

@@ -308,6 +309,7 @@ export const DefineDetector = (props: DefineDetectorProps) => {
308309
fullWidth: false,
309310
savedObjects: getSavedObjectsClient(),
310311
notifications: getNotifications(),
312+
dataSourceFilter: isDataSourceCompatible,
311313
}}
312314
/>
313315
);
@@ -328,6 +330,7 @@ export const DefineDetector = (props: DefineDetectorProps) => {
328330
notifications: getNotifications(),
329331
onSelectedDataSources: (dataSources) =>
330332
handleDataSourceChange(dataSources),
333+
dataSourceFilter: isDataSourceCompatible,
331334
}}
332335
/>
333336
);

public/pages/DetectorDetail/containers/DetectorDetail.tsx

+2-1
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ import {
7171
getNotifications,
7272
getSavedObjectsClient,
7373
} from '../../../services';
74-
import { constructHrefWithDataSourceId, getDataSourceFromURL } from '../../../pages/utils/helpers';
74+
import { constructHrefWithDataSourceId, getDataSourceFromURL, isDataSourceCompatible } from '../../../pages/utils/helpers';
7575

7676
export interface DetectorRouterProps {
7777
detectorId?: string;
@@ -430,6 +430,7 @@ export const DetectorDetail = (props: DetectorDetailProps) => {
430430
fullWidth: false,
431431
savedObjects: getSavedObjectsClient(),
432432
notifications: getNotifications(),
433+
dataSourceFilter: isDataSourceCompatible,
433434
}}
434435
/>
435436
);

public/pages/DetectorJobs/containers/DetectorJobs.tsx

+2
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ import { RouteComponentProps, useLocation } from 'react-router-dom';
3636
import {
3737
constructHrefWithDataSourceId,
3838
getDataSourceFromURL,
39+
isDataSourceCompatible,
3940
} from '../../../pages/utils/helpers';
4041
import {
4142
getDataSourceManagementPlugin,
@@ -140,6 +141,7 @@ export function DetectorJobs(props: DetectorJobsProps) {
140141
fullWidth: false,
141142
savedObjects: getSavedObjectsClient(),
142143
notifications: getNotifications(),
144+
dataSourceFilter: isDataSourceCompatible,
143145
}}
144146
/>
145147
);

public/pages/DetectorsList/containers/List/List.tsx

+2
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ import {
4848
constructHrefWithDataSourceId,
4949
getAllDetectorsQueryParamsWithDataSourceId,
5050
getVisibleOptions,
51+
isDataSourceCompatible,
5152
sanitizeSearchText,
5253
} from '../../../utils/helpers';
5354
import { EmptyDetectorMessage } from '../../components/EmptyMessage/EmptyMessage';
@@ -705,6 +706,7 @@ export const DetectorList = (props: ListProps) => {
705706
notifications: getNotifications(),
706707
onSelectedDataSources: (dataSources) =>
707708
handleDataSourceChange(dataSources),
709+
dataSourceFilter: isDataSourceCompatible,
708710
}}
709711
/>
710712
);

public/pages/Overview/containers/AnomalyDetectionOverview.tsx

+2-1
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ import {
6565
} from '../../../../public/services';
6666
import { RouteComponentProps } from 'react-router-dom';
6767
import queryString from 'querystring';
68-
import { getDataSourceFromURL, getSampleDetectorsQueryParamsWithDataSouceId } from '../../../../public/pages/utils/helpers';
68+
import { getDataSourceFromURL, getSampleDetectorsQueryParamsWithDataSouceId, isDataSourceCompatible } from '../../../../public/pages/utils/helpers';
6969
import { MDSStates } from '../../../models/interfaces';
7070

7171
interface AnomalyDetectionOverviewProps extends RouteComponentProps {
@@ -258,6 +258,7 @@ export function AnomalyDetectionOverview(props: AnomalyDetectionOverviewProps) {
258258
notifications: getNotifications(),
259259
onSelectedDataSources: (dataSources) =>
260260
handleDataSourceChange(dataSources),
261+
dataSourceFilter: isDataSourceCompatible,
261262
}}
262263
/>
263264
);

public/pages/ReviewAndCreate/containers/ReviewAndCreate.tsx

+2
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ import {
5656
import {
5757
constructHrefWithDataSourceId,
5858
getDataSourceFromURL,
59+
isDataSourceCompatible,
5960
} from '../../../pages/utils/helpers';
6061
import {
6162
getDataSourceManagementPlugin,
@@ -310,6 +311,7 @@ export function ReviewAndCreate(props: ReviewAndCreateProps) {
310311
fullWidth: false,
311312
savedObjects: getSavedObjectsClient(),
312313
notifications: getNotifications(),
314+
dataSourceFilter: isDataSourceCompatible,
313315
}}
314316
/>
315317
);

public/pages/utils/helpers.ts

+27
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,10 @@ import { ALL_INDICES, ALL_DETECTOR_STATES, MAX_DETECTORS, DEFAULT_QUERY_PARAMS }
2121
import { DETECTOR_STATE } from '../../../server/utils/constants';
2222
import { timeFormatter } from '@elastic/charts';
2323
import { getDataSourceEnabled, getDataSourcePlugin } from '../../services';
24+
import { DataSourceAttributes } from '../../../../../src/plugins/data_source/common/data_sources';
25+
import { SavedObject } from '../../../../../src/core/public';
26+
import * as pluginManifest from "../../../opensearch_dashboards.json";
27+
import semver from "semver";
2428

2529
export function sanitizeSearchText(searchValue: string): string {
2630
if (!searchValue || searchValue == '*') {
@@ -184,3 +188,26 @@ export const constructHrefWithDataSourceId = (
184188

185189
return `${basePath}?${url.toString()}`;
186190
};
191+
192+
export const isDataSourceCompatible = (dataSource: SavedObject<DataSourceAttributes>) => {
193+
if (
194+
'requiredOSDataSourcePlugins' in pluginManifest &&
195+
!pluginManifest.requiredOSDataSourcePlugins.every((plugin) =>
196+
dataSource.attributes.installedPlugins?.includes(plugin)
197+
)
198+
) {
199+
return false;
200+
}
201+
202+
// filter out data sources which is NOT in the support range of plugin
203+
if (
204+
'supportedOSDataSourceVersions' in pluginManifest &&
205+
!semver.satisfies(
206+
dataSource.attributes.dataSourceVersion,
207+
pluginManifest.supportedOSDataSourceVersions
208+
)
209+
) {
210+
return false;
211+
}
212+
return true;
213+
};

tsconfig.json

+2
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,8 @@
3131
"allowSyntheticDefaultImports": true,
3232
// Emits __importStar and __importDefault helpers for runtime babel ecosystem compatibility.
3333
"esModuleInterop": true,
34+
// Allow importing JSON files as modules.
35+
"resolveJsonModule": true,
3436
// Resolve modules in the same way as Node.js. Aka make `require` works the
3537
// same in TypeScript as it does in Node.js.
3638
"moduleResolution": "node",

yarn.lock

+25
Original file line numberDiff line numberDiff line change
@@ -425,6 +425,11 @@ color-name@1.1.3:
425425
resolved "https://registry.yarnpkg.com/color-name/-/color-name-1.1.3.tgz#a7d0558bd89c42f795dd42328f740831ca53bc25"
426426
integrity sha512-72fSenhMw2HZMTVHeCA9KCmpEIbzWiQsjN+BHcBbS9vr1mtt+vJjPdksIBNUmKAW8TFUDPJK5SUU3QhE9NEXDw==
427427

428+
color-name@^1.1.4:
429+
version "1.1.4"
430+
resolved "https://registry.yarnpkg.com/color-name/-/color-name-1.1.4.tgz#c2a09a87acbde69543de6f63fa3995c826c536a2"
431+
integrity sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==
432+
428433
combined-stream@^1.0.8:
429434
version "1.0.8"
430435
resolved "https://registry.yarnpkg.com/combined-stream/-/combined-stream-1.0.8.tgz#c3d45a8b34fd730631a110a8a2520682b31d5a7f"
@@ -489,6 +494,11 @@ cross-spawn@^7.0.0, cross-spawn@^7.0.3:
489494
shebang-command "^2.0.0"
490495
which "^2.0.1"
491496

497+
cssfontparser@^1.2.1:
498+
version "1.2.1"
499+
resolved "https://registry.yarnpkg.com/cssfontparser/-/cssfontparser-1.2.1.tgz#f4022fc8f9700c68029d542084afbaf425a3f3e3"
500+
integrity sha512-6tun4LoZnj7VN6YeegOVb67KBX/7JJsqvj+pv3ZA7F878/eN33AbGa5b/S/wXxS/tcp8nc40xRUrsPlxIyNUPg==
501+
492502
csstype@^3.0.2:
493503
version "3.1.2"
494504
resolved "https://registry.yarnpkg.com/csstype/-/csstype-3.1.2.tgz#1d4bf9d572f11c14031f0436e1c10bc1f571f50b"
@@ -964,6 +974,14 @@ isexe@^2.0.0:
964974
resolved "https://registry.yarnpkg.com/isexe/-/isexe-2.0.0.tgz#e8fbf374dc556ff8947a10dcb0572d633f2cfa10"
965975
integrity sha512-RHxMLp9lnKHGHRng9QFhRCMbYAcVpn69smSGcq3f36xjgVVWThj4qqLbTLlq7Ssj8B+fIQ1EuCEGI2lKsyQeIw==
966976

977+
jest-canvas-mock@^2.5.1:
978+
version "2.5.2"
979+
resolved "https://registry.yarnpkg.com/jest-canvas-mock/-/jest-canvas-mock-2.5.2.tgz#7e21ebd75e05ab41c890497f6ba8a77f915d2ad6"
980+
integrity sha512-vgnpPupjOL6+L5oJXzxTxFrlGEIbHdZqFU+LFNdtLxZ3lRDCl17FlTMM7IatoRQkrcyOTMlDinjUguqmQ6bR2A==
981+
dependencies:
982+
cssfontparser "^1.2.1"
983+
moo-color "^1.0.2"
984+
967985
joi@^17.7.0:
968986
version "17.9.2"
969987
resolved "https://registry.yarnpkg.com/joi/-/joi-17.9.2.tgz#8b2e4724188369f55451aebd1d0b1d9482470690"
@@ -1202,6 +1220,13 @@ moment@^2.24.0:
12021220
resolved "https://registry.yarnpkg.com/moment/-/moment-2.29.4.tgz#3dbe052889fe7c1b2ed966fcb3a77328964ef108"
12031221
integrity sha512-5LC9SOxjSc2HF6vO2CyuTDNivEdoz2IvyJJGj6X8DJ0eFyfszE0QiEd+iXmBvUP3WHxSjFH/vIsA0EN00cgr8w==
12041222

1223+
moo-color@^1.0.2:
1224+
version "1.0.3"
1225+
resolved "https://registry.yarnpkg.com/moo-color/-/moo-color-1.0.3.tgz#d56435f8359c8284d83ac58016df7427febece74"
1226+
integrity sha512-i/+ZKXMDf6aqYtBhuOcej71YSlbjT3wCO/4H1j8rPvxDJEifdwgg5MaFyu6iYAT8GBZJg2z0dkgK4YMzvURALQ==
1227+
dependencies:
1228+
color-name "^1.1.4"
1229+
12051230
ms@2.1.2:
12061231
version "2.1.2"
12071232
resolved "https://registry.yarnpkg.com/ms/-/ms-2.1.2.tgz#d09d1f357b443f493382a8eb3ccd183872ae6009"

0 commit comments

Comments
 (0)