Skip to content

Commit 89efbdf

Browse files
authored
Merge branch 'main' into manasvinibs/Issue-2799
Signed-off-by: Manasvini B Suryanarayana <manasvis@amazon.com>
2 parents feeaf5d + 61ea841 commit 89efbdf

31 files changed

+731
-224
lines changed

CHANGELOG.md

+3
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,7 @@ Inspired from [Keep a Changelog](https://keepachangelog.com/en/1.0.0/)
8686
- [Vis Builder] Add persistence to visualizations inner state ([#3751](https://github.com/opensearch-project/OpenSearch-Dashboards/pull/3751))
8787
- [Table Visualization] Move format table, consolidate types and add unit tests ([#3397](https://github.com/opensearch-project/OpenSearch-Dashboards/pull/3397))
8888
- Add plugin manifest config to define OpenSearch plugin dependency and verify if it is installed on the cluster ([#3116](https://github.com/opensearch-project/OpenSearch-Dashboards/pull/3116))
89+
- [Multiple Datasource] Support Amazon OpenSearch Serverless ([#3957](https://github.com/opensearch-project/OpenSearch-Dashboards/pull/3957))
8990

9091
### 🐛 Bug Fixes
9192

@@ -173,6 +174,7 @@ Inspired from [Keep a Changelog](https://keepachangelog.com/en/1.0.0/)
173174
- [Doc] Update DEVELOPER_GUIDE.md with added manual bootstrap timeout solution and max virtual memory error solution with docker ([#3764](https://github.com/opensearch-project/OpenSearch-Dashboards/pull/3764))
174175
- [Doc] Add COMMUNICATIONS.md with info about Slack, forum, office hours ([#3837](https://github.com/opensearch-project/OpenSearch-Dashboards/pull/3837))
175176
- [Doc] Add docker files and instructions for debugging Selenium functional tests ([#3747](https://github.com/opensearch-project/OpenSearch-Dashboards/pull/3747))
177+
- [Saved Object Service] Adds design doc for new Saved Object Service Interface for Custom Repository [#3954](https://github.com/opensearch-project/OpenSearch-Dashboards/pull/3954)
176178

177179
### 🛠 Maintenance
178180

@@ -202,6 +204,7 @@ Inspired from [Keep a Changelog](https://keepachangelog.com/en/1.0.0/)
202204
- [Multiple DataSource] Present the authentication type choices in a drop-down ([#3693](https://github.com/opensearch-project/OpenSearch-Dashboards/pull/3693))
203205
- [Console] Remove unused ul element and its custom styling ([#3993](https://github.com/opensearch-project/OpenSearch-Dashboards/pull/3993))
204206
- Fix EUI/OUI type errors ([#3798](https://github.com/opensearch-project/OpenSearch-Dashboards/pull/3798))
207+
- Remove unused Sass in `tile_map` plugin ([#4110](https://github.com/opensearch-project/OpenSearch-Dashboards/pull/4110))
205208

206209
### 🔩 Tests
207210

config/opensearch_dashboards.yml

+1-2
Original file line numberDiff line numberDiff line change
@@ -229,8 +229,7 @@
229229
# functionality in Visualization.
230230
# vis_builder.enabled: false
231231

232-
# Set the value of this setting to true to enable the experimental multiple data source
233-
# support feature. Use with caution.
232+
# Set the value of this setting to true to enable multiple data source feature.
234233
#data_source.enabled: false
235234
# Set the value of these settings to customize crypto materials to encryption saved credentials
236235
# in data sources.
Loading
Loading
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
@startuml
2+
title: Current Saved Object Service Flow
3+
actor User
4+
participant "Saved Object Client" as Client
5+
participant "Saved Object Repository" as Repo
6+
participant "Opensearch" as OS
7+
8+
User -> Client: Create Saved Object
9+
Client -> Repo: Create Saved Object
10+
Repo -> OS: Index Saved Object
11+
OS --> Repo: Saved Object Saved
12+
Client -> User: Saved Object Created
13+
User -> Client: Get Saved Object
14+
Client -> Repo: Get Saved Object
15+
Repo -> OS: Get Saved Object
16+
OS --> Repo: Return Saved Object
17+
Repo -> Client: Return Saved Object
18+
Client -> User: Saved Object Data
19+
@enduml
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
@startuml
2+
3+
title: Proposed Saved Object Service Flow
4+
5+
actor User
6+
7+
participant "OpenSearch-Dashboards" as OSD
8+
9+
box "Saved Object Service" #LightBlue
10+
participant "Saved Object Client" as Client
11+
participant "Repository Factory Provider" as Factory
12+
end box
13+
14+
box "Dashboards Storage Plugin" #LightYellow
15+
participant "Repository\n(e.g. PostgresRepository,\nDynamoDBRepository)" as Repo
16+
participant "Metadata Storage\n(e.g. Postgres, \nDynamoDB etc)" as Meta
17+
end box
18+
19+
autonumber
20+
group OSD Bootstrap
21+
Repo -> Factory: Register custom repository
22+
Factory -> Client: Returns repository
23+
Client -> OSD: Returns Saved Object Client
24+
end group
25+
User -> Client: Create Saved Object
26+
Client -> Repo: Create Saved Object
27+
Repo -> Meta: Create/Update Record
28+
Meta --> Repo: Saved Object Saved
29+
Client -> User: Saved Object Created
30+
User -> Client: Get Saved Object
31+
Client -> Repo: Get Saved Object
32+
Repo -> Meta: Fetch Saved Object from storage
33+
Meta --> Repo: Return Saved Object
34+
Repo -> Client: Return Saved Object
35+
Client -> User: Saved Object Data
36+
37+
skinparam BoxPadding 15
38+
@enduml
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,171 @@
1+
# Proposed Saved Object Service Interface for Custom Repository
2+
3+
## Introduction
4+
5+
The new saved object service interface for custom repository is a project that aims to improve scalability of the existing saved object service by introducing a new interface. The goal of this project is to provide a more efficient and flexible interface that will make it easier for developers to configure metadata of Dashboards in any different storage than OpenSearch, such as mysql, postgres, DDB, serverless (S3+ Athena).
6+
7+
Currently, Dashboards stores its metadata configuration inside OpenSearch index (called .kibana). This approach is by design of Dashboards and biased towards product decision by upstream which works seamlessly and out of the box for customers but it introduces challenges while operating at scale and providing high availability for Dashboards. While choosing OpenSearch as a storage for Dashboards metadata, availability of Dashboards depends on OpenSearch cluster’s availability and other cluster parameters such as cluster health, state, versions which could make Dashboards unavailable.
8+
9+
To mitigate above problem and unblock future extensibility of Dashboards, we are building Dashboards Meta storage adaptor to decouple Dashboards metadata storage from OpenSearch. This project will focus on introducing new interface in Saved Object Service using which developer can build their custom repository and save Dashboards metadata in storage of their choice.
10+
11+
The stakeholders of this new interface include the developers of the Dashboards and community contributors who wants to use other metadata store.
12+
13+
## Architecture Overview
14+
15+
The Saved Object Service is a critical component of Dashboards that provides a way to store and manage application data. It is built using a modular architecture that provides a high degree of flexibility and extensibility. The new interface will be designed to replace [ISavedObjectRepository](https://github.com/opensearch-project/OpenSearch-Dashboards/blob/main/src/core/server/saved_objects/service/lib/repository.ts#L134) implementation so that developers can build plugins that leverage the power of existing saved object service and use their own database to store and retrieve metadata of OpenSearch Dashboards.
16+
17+
### Current Architecture
18+
19+
The repository interface named [ISavedObjectRepository](https://github.com/opensearch-project/OpenSearch-Dashboards/blob/main/src/core/server/saved_objects/service/lib/repository.ts#L134) in OpenSearch-Dashboards is a module that provides an interface for managing saved objects. The [SavedObjectRepository](https://github.com/opensearch-project/OpenSearch-Dashboards/blob/main/src/core/server/saved_objects/service/lib/repository.ts#L139) is the implementation of [ISavedObjectRepository](https://github.com/opensearch-project/OpenSearch-Dashboards/blob/main/src/core/server/saved_objects/service/lib/repository.ts#L134), which uses OpenSearch index as it’s data store. It is responsible for storing, retrieving, and deleting saved objects for Dashboards, such as visualizations, dashboards, and searches.
20+
21+
The Saved Object Repository is built on top of the OpenSearch client and provides a simplified interface for working with OpenSearch. It uses the Saved Object Serializer to convert saved objects between their internal and external representations. The repository is then being consumed by Saved object client to create scoped saved object client.
22+
23+
![img](./img/current_saved_object_service_workflow.png)
24+
25+
### Proposed Architecture
26+
27+
- **Approach 1 (Preferred)**: The proposed architecture will add one more layer of abstraction in Saved Object Service. `The Repository Factory Provider` in OpenSearch Dashboards will be responsible for creating and managing instances of the Repository (e.g. SavedObjectRepository, PostgresRepository, DynamoDBRepository etc.), which is used to interact with the metadata storage that stores the saved objects. Currently we have an repository interface named [ISavedObjectRepository](https://github.com/opensearch-project/OpenSearch-Dashboards/blob/main/src/core/server/saved_objects/service/lib/repository.ts#L134), and the [SavedObjectRepository](https://github.com/opensearch-project/OpenSearch-Dashboards/blob/main/src/core/server/saved_objects/service/lib/repository.ts#L139) is the implementation, which use an OpenSearch index as its data store. This approach would make the implementation of [ISavedObjectRepository](https://github.com/opensearch-project/OpenSearch-Dashboards/blob/main/src/core/server/saved_objects/service/lib/repository.ts#L134) replaceable by plugin.
28+
29+
![img](./img/proposed_saved_object_service_workflow.png)
30+
31+
* Pros:
32+
* Only change needed in Dashboard is to introduce one more abstraction layer in Saved Object Service.
33+
* Adds opportunity for community developers to contribute for other meta store.
34+
35+
* Cons
36+
* Code reusability is low.
37+
<br/>
38+
39+
**POC**:
40+
1) Core Dashboards Change: https://github.com/bandinib-amzn/OpenSearch-Dashboards/commit/b9cfc14
41+
2) Postgres Repository Plugin: https://github.com/bandinib-amzn/metadata_plugin/commit/dac35f0
42+
43+
`SavedObjectsServiceSetup` provides interface to create custom Saved Object Repository.
44+
```
45+
/**
46+
* Set the default {@link SavedObjectRepositoryFactoryProvider | factory provider} for creating Saved Objects repository.
47+
* Only one repository can be set, subsequent calls to this method will fail.
48+
*/
49+
registerRepositoryFactoryProvider: (
50+
respositoryFactoryProvider: SavedObjectRepositoryFactoryProvider
51+
) => void;
52+
```
53+
54+
Here are the main steps involved in using the Saved Objects Repository Factory in Dashboards:
55+
1. Define the dependencies: The Saved Object Repository Factory Provider requires the function which creates instance of [ISavedObjectRepository](https://github.com/opensearch-project/OpenSearch-Dashboards/blob/main/src/core/server/saved_objects/service/lib/repository.ts#L134).
56+
```
57+
export const repositoryFactoryProvider: SavedObjectRepositoryFactoryProvider = (
58+
options: SavedObjectsRepositoryOptions
59+
) => {
60+
.
61+
.
62+
.
63+
return new PostgresRepository({
64+
typeRegistry,
65+
serializer,
66+
migrator,
67+
allowedTypes,
68+
});
69+
}
70+
```
71+
2. Register the provider: Register the repository factory provider with right dependencies.
72+
```
73+
core.savedObjects.registerRepositoryFactoryProvider(repositoryFactoryProvider);
74+
```
75+
3. Implement the Saved Object Operations for chosen storage type: Implement the CRUD and other operations for contracts defined in [ISavedObjectRepository](https://github.com/opensearch-project/OpenSearch-Dashboards/blob/main/src/core/server/saved_objects/service/lib/repository.ts#L134)
76+
```
77+
async create<T = unknown>(
78+
type: string,
79+
attributes: T,
80+
options: SavedObjectsCreateOptions = {}
81+
): Promise<SavedObject<T>> {
82+
...
83+
}
84+
85+
async get<T = unknown>(
86+
type: string,
87+
id: string,
88+
options: SavedObjectsBaseOptions = {}
89+
): Promise<SavedObject<T>> {
90+
...
91+
}
92+
93+
async update<T = unknown>(
94+
type: string,
95+
id: string,
96+
attributes: Partial<T>,
97+
options: SavedObjectsUpdateOptions = {}
98+
): Promise<SavedObjectsUpdateResponse<T>> {
99+
...
100+
}
101+
102+
async deleteFromNamespaces(
103+
type: string,
104+
id: string,
105+
namespaces: string[],
106+
options: SavedObjectsDeleteFromNamespacesOptions = {}
107+
): Promise<SavedObjectsDeleteFromNamespacesResponse> {
108+
...
109+
}
110+
.
111+
.
112+
.
113+
```
114+
115+
- **Approach 2**: Build external plugin and using saved object client wrapper or client factory provider injection mechanism we can build custom object for Postgres or other DB.
116+
117+
* Pros:
118+
* No changes in core Dashboards. That means we can keep Dashboards as it is with very minimal changes.
119+
120+
121+
* Cons
122+
* Code reusability is low.
123+
* Some components of Saved object service such as Serializer, Type registry, interface to create internal and scoped repository are only available during Saved Object Service Start. As per the current architecture, first Saved Object Service Setup → Plugin Setup → Saved Object Service Start → Plugin Start. Some core plugin (e.g. opensearch_dashboards_usage_collection) calls find operation before plugin start and it fails because some components are still not available before plugin start.
124+
<br/>
125+
126+
**POC**: https://github.com/bandinib-amzn/metadata_plugin/compare/f040daf...89213eb
127+
128+
129+
- **Approach 3**: In this approach, we just extend the `SavedObjectsRepository` class and override CRUD and other saved object operation in core Dashboards.
130+
131+
* Pros:
132+
* As we are extending the repository in core saved object service itself, we can reuse the validation and utility functions for other database options.
133+
134+
135+
* Cons
136+
* Changes in core Dashboards : We will be making considerable changes in critical component of Dashboards.
137+
* With this approach, user will have to use the data storage option that we choose.
138+
<br/>
139+
140+
**POC**: https://github.com/bandinib-amzn/OpenSearch-Dashboards/compare/main...22d7f30
141+
142+
## Implementation Details
143+
144+
145+
| Repository | Component | Change |
146+
| ----------- | ----------- | ----------- |
147+
| OpenSearch-Dashboards | Saved Object Service | Add Saved object repository factory provider |
148+
| OpenSearch-Dashboards | Config | Configuration for metadata storage |
149+
| MetaStorage-Plugin [Name TBD] | Plugin / Extension | We will build new plugin for Postgres. This is use case for new interface in Saved Object Repository. |
150+
151+
### Configuration for metadata storage:
152+
```
153+
metaStorage.enabled: true
154+
metaStorage.config: {
155+
type: 'xxxx',
156+
hostName: 'xxxx',
157+
userName: 'xxxx',
158+
password: 'xxxx',
159+
port: xxxx,
160+
}
161+
```
162+
163+
## Testing and Quality Assurance
164+
165+
### Testing Approach
166+
167+
The following testing approach will be used to ensure the quality of the system:
168+
169+
1. **Unit testing**: Metadata store plugin will be thoroughly unit tested to ensure it meets its requirements and performs as expected. Also we will add new test cases in OpenSearch-Dashboards to test new repository factory provider.
170+
2. **Integration testing**: Components will be integrated and tested together to ensure they work together seamlessly and without conflicts.
171+

package.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@
136136
"@hapi/podium": "^4.1.3",
137137
"@hapi/vision": "^6.1.0",
138138
"@hapi/wreck": "^17.1.0",
139-
"@opensearch-project/opensearch": "^2.1.0",
139+
"@opensearch-project/opensearch": "^2.2.0",
140140
"@osd/ace": "1.0.0",
141141
"@osd/analytics": "1.0.0",
142142
"@osd/apm-config-loader": "1.0.0",
@@ -169,7 +169,7 @@
169169
"dns-sync": "^0.2.1",
170170
"elastic-apm-node": "^3.7.0",
171171
"elasticsearch": "^16.7.0",
172-
"http-aws-es": "6.0.0",
172+
"http-aws-es": "npm:@zhongnansu/http-aws-es@6.0.1",
173173
"execa": "^4.0.2",
174174
"expiry-js": "0.1.7",
175175
"fast-deep-equal": "^3.1.1",

packages/osd-opensearch/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
"osd:watch": "../../scripts/use_node scripts/build --watch"
1313
},
1414
"dependencies": {
15-
"@opensearch-project/opensearch": "^2.1.0",
15+
"@opensearch-project/opensearch": "^2.2.0",
1616
"@osd/dev-utils": "1.0.0",
1717
"abort-controller": "^3.0.0",
1818
"chalk": "^4.1.0",
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
# Version 1.3.10 Release Notes
2+
3+
### 🛡 Security
4+
5+
- [CVE-2020-15366][1.x] Bump ajv from 4.11.8 to 6.12.6 ([#4035](https://github.com/opensearch-project/OpenSearch-Dashboards/pull/4035))
6+
- [CVE-2022-48285][1.x] Bump jszip from 3.7.1 to 3.10.1 ([#4011](https://github.com/opensearch-project/OpenSearch-Dashboards/pull/4011))
7+
- [CVE-2021-35065][1.x] Bump glob-parent from 6.0.0 to 6.0.2 ([#4005](https://github.com/opensearch-project/OpenSearch-Dashboards/pull/4005))
8+
- [CVE-2022-25851][1.x] Bump jpeg-js from 0.4.1 to 0.4.4 ([#3860](https://github.com/opensearch-project/OpenSearch-Dashboards/pull/3860))
9+
- [CVE-2022-25858][1.x] Bump terser from 4.8.0 to 4.8.1 ([#3786](https://github.com/opensearch-project/OpenSearch-Dashboards/pull/3786))
10+
- [CVE-2021-23490][1.x] Bump parse-link-header from 1.0.1 to 2.0.0 ([#3820](https://github.com/opensearch-project/OpenSearch-Dashboards/pull/3820))
11+
- [CVE-2021-3765][1.x] Bump validator from 8.2.0 to 13.9.0 ([#3753](https://github.com/opensearch-project/OpenSearch-Dashboards/pull/3753))
12+
- [CVE-2022-25758][1.x] Bump scss-tokenizer from 0.3.0 to 0.4.3 ([#3789](https://github.com/opensearch-project/OpenSearch-Dashboards/pull/3789))
13+
- [CVE-2021-3803][1.x] Bump nth-check from 1.0.2 to 2.0.1 ([#3745](https://github.com/opensearch-project/OpenSearch-Dashboards/pull/3745))
14+
- Bump highlight.js from 9.18.5 to 10.7.3 to solve security concerns ([#4062](https://github.com/opensearch-project/OpenSearch-Dashboards/pull/4062))
15+
16+
### 📈 Features/Enhancements
17+
18+
- Add tooltip to help icon ([#3872](https://github.com/opensearch-project/OpenSearch-Dashboards/pull/3872))
19+
20+
### 🐛 Bug Fixes
21+
22+
- [TSVB] Fix the link to "serial differencing aggregation" documentation ([#3503](https://github.com/opensearch-project/OpenSearch-Dashboards/pull/3503))
23+
24+
### 📝 Documentation
25+
26+
- Update jest documentation links ([#3939](https://github.com/opensearch-project/OpenSearch-Dashboards/pull/3939))
27+
28+
### 🛠 Maintenance
29+
30+
- Add threshold to code coverage changes for project ([#4050](https://github.com/opensearch-project/OpenSearch-Dashboards/pull/4050))
31+
- Temporarily hardcode chromedriver to 112.0.0 to enable all ftr tests ([#4039]())
32+
- Update MAINTAINERS.md and CODEOWNERS ([#3938](https://github.com/opensearch-project/OpenSearch-Dashboards/pull/3938))
33+
- Add opensearch-dashboards-docker-dev to .gitignore ([#3781](https://github.com/opensearch-project/OpenSearch-Dashboards/pull/3781))

src/plugins/data_source/common/data_sources/types.ts

+6
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ export interface SigV4Content extends SavedObjectAttributes {
2525
accessKey: string;
2626
secretKey: string;
2727
region: string;
28+
service?: SigV4ServiceName;
2829
}
2930

3031
export interface UsernamePasswordTypedContent extends SavedObjectAttributes {
@@ -37,3 +38,8 @@ export enum AuthType {
3738
UsernamePasswordType = 'username_password',
3839
SigV4 = 'sigv4',
3940
}
41+
42+
export enum SigV4ServiceName {
43+
OpenSearch = 'es',
44+
OpenSearchServerless = 'aoss',
45+
}

src/plugins/data_source/opensearch_dashboards.json

+2-1
Original file line numberDiff line numberDiff line change
@@ -5,5 +5,6 @@
55
"server": true,
66
"ui": true,
77
"requiredPlugins": [],
8-
"optionalPlugins": []
8+
"optionalPlugins": [],
9+
"extraPublicDirs": ["common/data_sources"]
910
}

src/plugins/data_source/server/client/configure_client.test.ts

+24
Original file line numberDiff line numberDiff line change
@@ -167,6 +167,30 @@ describe('configureClient', () => {
167167
expect(decodeAndDecryptSpy).toHaveBeenCalledTimes(2);
168168
});
169169

170+
test('configure client with auth.type == sigv4, service == aoss, should successfully call new Client()', async () => {
171+
savedObjectsMock.get.mockReset().mockResolvedValueOnce({
172+
id: DATA_SOURCE_ID,
173+
type: DATA_SOURCE_SAVED_OBJECT_TYPE,
174+
attributes: {
175+
...dataSourceAttr,
176+
auth: {
177+
type: AuthType.SigV4,
178+
credentials: { ...sigV4AuthContent, service: 'aoss' },
179+
},
180+
},
181+
references: [],
182+
});
183+
184+
jest.spyOn(cryptographyMock, 'decodeAndDecrypt').mockResolvedValue({
185+
decryptedText: 'accessKey',
186+
encryptionContext: { endpoint: 'http://localhost' },
187+
});
188+
189+
await configureClient(dataSourceClientParams, clientPoolSetup, config, logger);
190+
191+
expect(ClientMock).toHaveBeenCalledTimes(1);
192+
});
193+
170194
test('configure test client for non-exist datasource should not call saved object api, nor decode any credential', async () => {
171195
const decodeAndDecryptSpy = jest.spyOn(cryptographyMock, 'decodeAndDecrypt').mockResolvedValue({
172196
decryptedText: 'password',

0 commit comments

Comments
 (0)