-
Notifications
You must be signed in to change notification settings - Fork 885
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Multiple Datasource][Version Decoupling] Add data source engine type to data source saved object #7026
[Multiple Datasource][Version Decoupling] Add data source engine type to data source saved object #7026
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
fix: | ||
- [MDS] Add data source engine type to data source saved object ([#7026](https://github.com/opensearch-project/OpenSearch-Dashboards/pull/7026)) |
Original file line number | Diff line number | Diff line change | ||
---|---|---|---|---|
|
@@ -10,6 +10,7 @@ export interface DataSourceAttributes extends SavedObjectAttributes { | |||
description?: string; | ||||
endpoint: string; | ||||
dataSourceVersion?: string; | ||||
dataSourceEngineType?: DataSourceEngineType; | ||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. do we need a migration? i dont think so right OpenSearch-Dashboards/src/plugins/data_source/server/saved_objects/data_source.ts Line 44 in a4aa682
it's optional field. so think it doesn't need it. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. that's why this field is marked optional yes |
||||
installedPlugins?: string[]; | ||||
auth: { | ||||
type: AuthType | string; | ||||
|
@@ -52,3 +53,10 @@ export enum SigV4ServiceName { | |||
} | ||||
|
||||
export { DataSourceError } from './error'; | ||||
|
||||
export enum DataSourceEngineType { | ||||
OpenSearch = 'OpenSearch', | ||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. How come not If the data source then is undefined then it's assumed vs using I know in the repo it's a mixed casing with enums but not sure if using default will cause some issues lowercase so maybe
the serverless banking off that we assume it's OpenSearch. The legacy because internally we reference it as legacy internally [example] and NONE because it's matches the pattern to other enums in the repo [example] There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why is This engine type is retrieved when the data source object is pulled together and assuming a default just makes no sense to the users where the default just mean OS cluster ? This info is not leveraged in global url states but maybe share the flint issues link if any so we can double check. (is flint even open sourced ?) Per the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
but i dont think elasticsearch is either which is why internally codewise we refer to elasticsearch references as
do we display this info to the user in functional purposes? have we verified this with legal? previous requirements were no trademark displays from that legacy engine. so if we plan on displaying this info could be an issue. if not then i would consider that internally codewise since forking we reference elasticsearch as legacy. so it would be an antipattern There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this info is not displayed to user, would like to follow up on this legal verification mentioned here, do you have any previous ref or poc from legal ? have no problem to switch all reference of elasticsearch to legacy |
||||
OpenSearchServerless = 'OpenSearch Serverless', | ||||
Elasticsearch = 'Elasticsearch', | ||||
NA = 'No Engine Type Available', | ||||
} |
Original file line number | Diff line number | Diff line change | ||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
@@ -5,7 +5,9 @@ | |||||||||||||
|
||||||||||||||
import { OpenSearchClient } from 'opensearch-dashboards/server'; | ||||||||||||||
import { createDataSourceError } from '../lib/error'; | ||||||||||||||
import { SigV4ServiceName } from '../../common/data_sources'; | ||||||||||||||
import { DataSourceEngineType, SigV4ServiceName } from '../../common/data_sources'; | ||||||||||||||
import { DataSourceInfo } from '../types'; | ||||||||||||||
|
||||||||||||||
export class DataSourceConnectionValidator { | ||||||||||||||
constructor( | ||||||||||||||
private readonly callDataCluster: OpenSearchClient, | ||||||||||||||
|
@@ -36,26 +38,42 @@ | |||||||||||||
} | ||||||||||||||
} | ||||||||||||||
|
||||||||||||||
async fetchDataSourceVersion() { | ||||||||||||||
let dataSourceVersion = ''; | ||||||||||||||
async fetchDataSourceInfo() { | ||||||||||||||
const dataSourceInfo: DataSourceInfo = { | ||||||||||||||
dataSourceVersion: '', | ||||||||||||||
dataSourceEngineType: DataSourceEngineType.NA, | ||||||||||||||
}; | ||||||||||||||
|
||||||||||||||
try { | ||||||||||||||
// OpenSearch Serverless does not have version concept | ||||||||||||||
if ( | ||||||||||||||
this.dataSourceAttr.auth?.credentials?.service === SigV4ServiceName.OpenSearchServerless | ||||||||||||||
) { | ||||||||||||||
return dataSourceVersion; | ||||||||||||||
dataSourceInfo.dataSourceEngineType = DataSourceEngineType.OpenSearchServerless; | ||||||||||||||
return dataSourceInfo; | ||||||||||||||
} | ||||||||||||||
|
||||||||||||||
await this.callDataCluster | ||||||||||||||
.info() | ||||||||||||||
.then((response) => response.body) | ||||||||||||||
.then((body) => { | ||||||||||||||
dataSourceVersion = body.version.number; | ||||||||||||||
dataSourceInfo.dataSourceVersion = body.version.number; | ||||||||||||||
|
||||||||||||||
if ( | ||||||||||||||
body.version.distribution !== null && | ||||||||||||||
body.version.distribution !== undefined && | ||||||||||||||
body.version.distribution === 'opensearch' | ||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nit:
Comment on lines
+62
to
+65
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
This can be simplified |
||||||||||||||
) { | ||||||||||||||
dataSourceInfo.dataSourceEngineType = DataSourceEngineType.OpenSearch; | ||||||||||||||
} else { | ||||||||||||||
dataSourceInfo.dataSourceEngineType = DataSourceEngineType.Elasticsearch; | ||||||||||||||
} | ||||||||||||||
}); | ||||||||||||||
|
||||||||||||||
return dataSourceVersion; | ||||||||||||||
return dataSourceInfo; | ||||||||||||||
} catch (e) { | ||||||||||||||
// return empty dataSource version instead of throwing exception in case info() api call fails | ||||||||||||||
return dataSourceVersion; | ||||||||||||||
// return default dataSourceInfo instead of throwing exception in case info() api call fails | ||||||||||||||
return dataSourceInfo; | ||||||||||||||
} | ||||||||||||||
} | ||||||||||||||
|
||||||||||||||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -165,7 +165,9 @@ describe(`Fetch DataSource MetaData ${URL}`, () => { | |
|
||
const router = httpSetup.createRouter(''); | ||
dataSourceClient.info.mockImplementationOnce(() => | ||
opensearchClientMock.createSuccessTransportRequestPromise({ version: { number: '2.11.0' } }) | ||
opensearchClientMock.createSuccessTransportRequestPromise({ | ||
version: { number: '2.11.0', distribution: 'opensearch' }, | ||
}) | ||
); | ||
|
||
const installedPlugins = [ | ||
|
@@ -201,6 +203,7 @@ describe(`Fetch DataSource MetaData ${URL}`, () => { | |
.expect(200); | ||
expect(result.body).toEqual({ | ||
dataSourceVersion: '2.11.0', | ||
dataSourceEngineType: 'OpenSearch', | ||
installedPlugins: ['opensearch-ml', 'opensearch-sql'], | ||
}); | ||
expect(dataSourceServiceSetupMock.getDataSourceClient).toHaveBeenCalledWith( | ||
|
@@ -224,6 +227,7 @@ describe(`Fetch DataSource MetaData ${URL}`, () => { | |
.expect(200); | ||
expect(result.body).toEqual({ | ||
dataSourceVersion: '2.11.0', | ||
dataSourceEngineType: 'OpenSearch', | ||
installedPlugins: ['opensearch-ml', 'opensearch-sql'], | ||
}); | ||
}); | ||
|
@@ -324,6 +328,7 @@ describe(`Fetch DataSource MetaData ${URL}`, () => { | |
.expect(200); | ||
expect(result.body).toEqual({ | ||
dataSourceVersion: '2.11.0', | ||
dataSourceEngineType: 'OpenSearch', | ||
installedPlugins: ['opensearch-ml', 'opensearch-sql'], | ||
}); | ||
}); | ||
|
@@ -338,6 +343,7 @@ describe(`Fetch DataSource MetaData ${URL}`, () => { | |
.expect(200); | ||
expect(result.body).toEqual({ | ||
dataSourceVersion: '2.11.0', | ||
dataSourceEngineType: 'OpenSearch', | ||
installedPlugins: ['opensearch-ml', 'opensearch-sql'], | ||
}); | ||
}); | ||
|
@@ -352,6 +358,7 @@ describe(`Fetch DataSource MetaData ${URL}`, () => { | |
.expect(200); | ||
expect(result.body).toEqual({ | ||
dataSourceVersion: '2.11.0', | ||
dataSourceEngineType: 'OpenSearch', | ||
installedPlugins: ['opensearch-ml', 'opensearch-sql'], | ||
}); | ||
}); | ||
|
@@ -366,6 +373,7 @@ describe(`Fetch DataSource MetaData ${URL}`, () => { | |
.expect(200); | ||
expect(result.body).toEqual({ | ||
dataSourceVersion: '2.11.0', | ||
dataSourceEngineType: 'OpenSearch', | ||
installedPlugins: ['opensearch-ml', 'opensearch-sql'], | ||
Comment on lines
374
to
377
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is this is the only place where we are comparing result.body during testing? What if we are testing result.body at other places like functional, integration? It will break, right? We will need to include dataSourceEngineType everyehwhere. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. yes as |
||
}); | ||
}); | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: prolly keeping in line with version which makes sense too.
but might be redundant to put
dataSource
in the field name since it's apart of the DataSource attributes. but i also understand the concept of data sources has different meanings even within this repo so might make sense to specify.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yeah you got the point, the
dataSource
prefix was added intentionally just to distinguish with other data source terms