Skip to content

Commit

Permalink
Merge branch 'main' into 3967-Add-new-or-remove-extra-tags-and-styles
Browse files Browse the repository at this point in the history
Signed-off-by: Josh Romero <rmerqg@amazon.com>
  • Loading branch information
joshuarrrr authored Jun 6, 2023
2 parents 14ffe92 + 5c5de03 commit 6b8a820
Show file tree
Hide file tree
Showing 241 changed files with 6,228 additions and 11,381 deletions.
2 changes: 1 addition & 1 deletion .github/CODEOWNERS
Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
@@ -1 +1 @@
* @ananzh @kavilla @seanneumann @AMoo-Miki @ashwin-pc @joshuarrrr @abbyhu2000 @zengyan-amazon @kristenTian @zhongnansu @manasvinibs
* @ananzh @kavilla @seanneumann @AMoo-Miki @ashwin-pc @joshuarrrr @abbyhu2000 @zengyan-amazon @kristenTian @zhongnansu @manasvinibs @ZilongX @Flyingliuhub
25 changes: 5 additions & 20 deletions .github/workflows/build_and_test_workflow.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,13 @@ env:
TEST_OPENSEARCH_TRANSPORT_PORT: 9403
TEST_OPENSEARCH_PORT: 9400
OSD_SNAPSHOT_SKIP_VERIFY_CHECKSUM: true
# Version 112.0.5615.0
CHROME_VERSION: 1109208
NODE_OPTIONS: "--max-old-space-size=6144 --dns-result-order=ipv4first"

jobs:
build-lint-test:
name: Build and Verify on ${{ matrix.name }}
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, windows-latest]
include:
Expand Down Expand Up @@ -137,22 +137,6 @@ jobs:
steps:
- run: echo Running functional tests for ciGroup${{ matrix.group }}

- name: Setup Chrome
id: setup-chrome
uses: browser-actions/setup-chrome@v1
with:
chrome-version: ${{ env.CHROME_VERSION }}

- name: Set Chrome Path
if: matrix.os != 'windows-latest'
run: |
echo "TEST_BROWSER_BINARY_PATH=${{ steps.setup-chrome.outputs.chrome-path }}" >> $GITHUB_ENV
- name: Set Chrome Path (Windows)
if: matrix.os == 'windows-latest'
run: |
echo "TEST_BROWSER_BINARY_PATH=${{ steps.setup-chrome.outputs.chrome-path }}" >> $env:GITHUB_ENV
- name: Configure git's autocrlf (Windows only)
if: matrix.os == 'windows-latest'
run: |
Expand Down Expand Up @@ -403,6 +387,7 @@ jobs:
with:
name: ${{ matrix.version }}-test-failures
path: |
./artifacts/bwc_tmp/test/cypress/videos/without-security/*
./artifacts/bwc_tmp/test/cypress/screenshots/without-security/*
./artifacts/bwc_tmp/test/cypress/videos/*
./artifacts/bwc_tmp/test/cypress/screenshots/*
./artifacts/bwc_tmp/test/cypress/results/*
retention-days: 1
7 changes: 5 additions & 2 deletions .github/workflows/cypress_workflow.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,10 @@ env:
START_CMD: 'node ../scripts/opensearch_dashboards --dev --no-base-path --no-watch'
OPENSEARCH_SNAPSHOT_CMD: 'node ../scripts/opensearch snapshot'
SPEC: 'cypress/integration/core-opensearch-dashboards/opensearch-dashboards/**/*.js,'
CYPRESS_ENV: 'env CYPRESS_VISBUILDER_ENABLED=true CYPRESS_DATASOURCE_MANAGEMENT_ENABLED=false'
CYPRESS_BROWSER: 'chromium'
CYPRESS_VISBUILDER_ENABLED: true
CYPRESS_DATASOURCE_MANAGEMENT_ENABLED: false
OSD_SNAPSHOT_SKIP_VERIFY_CHECKSUM: true

jobs:
cypress-tests:
Expand Down Expand Up @@ -76,7 +79,7 @@ jobs:
working-directory: ${{ env.FTR_PATH }}
start: ${{ env.OPENSEARCH_SNAPSHOT_CMD }}, ${{ env.START_CMD }}
wait-on: 'http://localhost:9200, http://localhost:5601'
command: ${{ env.CYPRESS_ENV }} yarn cypress:run-without-security --browser chromium --spec ${{ env.SPEC }}
command: yarn cypress:run-without-security --browser ${{ env.CYPRESS_BROWSER }} --spec ${{ env.SPEC }}

# Screenshots are only captured on failure, will change this once we do visual regression tests
- uses: actions/upload-artifact@v3
Expand Down
2 changes: 1 addition & 1 deletion .i18nrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@
"src/plugins/telemetry_management_section"
],
"tileMap": "src/plugins/tile_map",
"timeline": ["src/plugins/timeline", "src/plugins/vis_type_timeline"],
"timeline": ["src/plugins/vis_type_timeline"],
"uiActions": "src/plugins/ui_actions",
"visDefaultEditor": "src/plugins/vis_default_editor",
"visTypeMarkdown": "src/plugins/vis_type_markdown",
Expand Down
1 change: 1 addition & 0 deletions .lycheeexclude
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ http://www.opensearch.org/painlessDocs
https://www.hostedgraphite.com/
https://connectionurl.com
http://169.254.169.254/latest/meta-data/
http://company.net/*

# External urls
https://www.zeek.org/
Expand Down
2 changes: 1 addition & 1 deletion .node-version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
14.21.3
18.16.0
2 changes: 1 addition & 1 deletion .nvmrc
Original file line number Diff line number Diff line change
@@ -1 +1 @@
14.21.3
18.16.0
736 changes: 521 additions & 215 deletions CHANGELOG.md

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
ARG NODE_VERSION=14.20.1
ARG NODE_VERSION=18.16.0
FROM node:${NODE_VERSION} AS base

ENV HOME '.'
Expand Down
2 changes: 2 additions & 0 deletions MAINTAINERS.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ This document contains a list of maintainers in this repo. See [opensearch-proje
| Kristen Tian | [kristenTian](https://github.com/kristenTian) | Amazon |
| Zhongnan Su | [zhongnansu](https://github.com/zhongnansu) | Amazon |
| Manasvini B Suryanarayana | [manasvinibs](https://github.com/manasvinibs) | Amazon |
| Tao Liu | [Flyingliuhub](https://github.com/Flyingliuhub) | Amazon |
| Zilong Xia | [ZilongX](https://github.com/ZilongX) | Amazon |

## Emeritus

Expand Down
7 changes: 0 additions & 7 deletions cypress/integration/with-security/check_advanced_settings.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,6 @@ describe('verify the advanced settings are saved', () => {
.should('eq', 'true');
});

it('the Timeline default columns field is set to 4', () => {
cy.get('[data-test-subj="advancedSetting-editField-timeline:default_columns"]').should(
'have.value',
4
);
});

it('the Timeline Maximum buckets field is set to 4', () => {
cy.get('[data-test-subj="advancedSetting-editField-timeline:max_buckets"]').should(
'have.value',
Expand Down
3 changes: 0 additions & 3 deletions cypress/integration/with-security/helpers/generate_data.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,6 @@ describe('Generating BWC test data with security', () => {
it('adds advanced settings', () => {
miscUtils.visitPage('app/management/opensearch-dashboards/settings');
cy.get('[data-test-subj="advancedSetting-editField-theme:darkMode"]').click();
cy.get('[data-test-subj="advancedSetting-editField-timeline:default_columns"]').type(
'{selectAll}4'
);
cy.get('[data-test-subj="advancedSetting-editField-timeline:max_buckets"]').type(
'{selectAll}4'
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,6 @@ describe('verify the advanced settings are saved', () => {
.should('eq', 'true');
});

it('the Timeline default columns field is set to 4', () => {
cy.get('[data-test-subj="advancedSetting-editField-timeline:default_columns"]').should(
'have.value',
4
);
});

it('the Timeline Maximum buckets field is set to 4', () => {
cy.get('[data-test-subj="advancedSetting-editField-timeline:max_buckets"]').should(
'have.value',
Expand Down
3 changes: 0 additions & 3 deletions cypress/integration/without-security/helpers/generate_data.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,6 @@ describe('Generating BWC test data without security', () => {
it('adds advanced settings', () => {
miscUtils.visitPage('app/management/opensearch-dashboards/settings');
cy.get('[data-test-subj="advancedSetting-editField-theme:darkMode"]').click();
cy.get('[data-test-subj="advancedSetting-editField-timeline:default_columns"]').type(
'{selectAll}4'
);
cy.get('[data-test-subj="advancedSetting-editField-timeline:max_buckets"]').type(
'{selectAll}4'
);
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
@startuml
title: Current Saved Object Service Flow
actor User
participant "Saved Object Client" as Client
participant "Saved Object Repository" as Repo
participant "Opensearch" as OS

User -> Client: Create Saved Object
Client -> Repo: Create Saved Object
Repo -> OS: Index Saved Object
OS --> Repo: Saved Object Saved
Client -> User: Saved Object Created
User -> Client: Get Saved Object
Client -> Repo: Get Saved Object
Repo -> OS: Get Saved Object
OS --> Repo: Return Saved Object
Repo -> Client: Return Saved Object
Client -> User: Saved Object Data
@enduml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
@startuml

title: Proposed Saved Object Service Flow

actor User

participant "OpenSearch-Dashboards" as OSD

box "Saved Object Service" #LightBlue
participant "Saved Object Client" as Client
participant "Repository Factory Provider" as Factory
end box

box "Dashboards Storage Plugin" #LightYellow
participant "Repository\n(e.g. PostgresRepository,\nDynamoDBRepository)" as Repo
participant "Metadata Storage\n(e.g. Postgres, \nDynamoDB etc)" as Meta
end box

autonumber
group OSD Bootstrap
Repo -> Factory: Register custom repository
Factory -> Client: Returns repository
Client -> OSD: Returns Saved Object Client
end group
User -> Client: Create Saved Object
Client -> Repo: Create Saved Object
Repo -> Meta: Create/Update Record
Meta --> Repo: Saved Object Saved
Client -> User: Saved Object Created
User -> Client: Get Saved Object
Client -> Repo: Get Saved Object
Repo -> Meta: Fetch Saved Object from storage
Meta --> Repo: Return Saved Object
Repo -> Client: Return Saved Object
Client -> User: Saved Object Data

skinparam BoxPadding 15
@enduml
171 changes: 171 additions & 0 deletions docs/saved_objects/saved_object_repository_factory_design.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,171 @@
# Proposed Saved Object Service Interface for Custom Repository

## Introduction

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).

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.

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.

The stakeholders of this new interface include the developers of the Dashboards and community contributors who wants to use other metadata store.

## Architecture Overview

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.

### Current Architecture

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.

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.

![img](./img/current_saved_object_service_workflow.png)

### Proposed Architecture

- **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.

![img](./img/proposed_saved_object_service_workflow.png)

* Pros:
* Only change needed in Dashboard is to introduce one more abstraction layer in Saved Object Service.
* Adds opportunity for community developers to contribute for other meta store.

* Cons
* Code reusability is low.
<br/>

**POC**:
1) Core Dashboards Change: https://github.com/bandinib-amzn/OpenSearch-Dashboards/commit/b9cfc14
2) Postgres Repository Plugin: https://github.com/bandinib-amzn/metadata_plugin/commit/dac35f0

`SavedObjectsServiceSetup` provides interface to create custom Saved Object Repository.
```
/**
* Set the default {@link SavedObjectRepositoryFactoryProvider | factory provider} for creating Saved Objects repository.
* Only one repository can be set, subsequent calls to this method will fail.
*/
registerRepositoryFactoryProvider: (
respositoryFactoryProvider: SavedObjectRepositoryFactoryProvider
) => void;
```

Here are the main steps involved in using the Saved Objects Repository Factory in Dashboards:
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).
```
export const repositoryFactoryProvider: SavedObjectRepositoryFactoryProvider = (
options: SavedObjectsRepositoryOptions
) => {
.
.
.
return new PostgresRepository({
typeRegistry,
serializer,
migrator,
allowedTypes,
});
}
```
2. Register the provider: Register the repository factory provider with right dependencies.
```
core.savedObjects.registerRepositoryFactoryProvider(repositoryFactoryProvider);
```
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)
```
async create<T = unknown>(
type: string,
attributes: T,
options: SavedObjectsCreateOptions = {}
): Promise<SavedObject<T>> {
...
}
async get<T = unknown>(
type: string,
id: string,
options: SavedObjectsBaseOptions = {}
): Promise<SavedObject<T>> {
...
}
async update<T = unknown>(
type: string,
id: string,
attributes: Partial<T>,
options: SavedObjectsUpdateOptions = {}
): Promise<SavedObjectsUpdateResponse<T>> {
...
}
async deleteFromNamespaces(
type: string,
id: string,
namespaces: string[],
options: SavedObjectsDeleteFromNamespacesOptions = {}
): Promise<SavedObjectsDeleteFromNamespacesResponse> {
...
}
.
.
.
```

- **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.

* Pros:
* No changes in core Dashboards. That means we can keep Dashboards as it is with very minimal changes.


* Cons
* Code reusability is low.
* 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.
<br/>

**POC**: https://github.com/bandinib-amzn/metadata_plugin/compare/f040daf...89213eb


- **Approach 3**: In this approach, we just extend the `SavedObjectsRepository` class and override CRUD and other saved object operation in core Dashboards.

* Pros:
* As we are extending the repository in core saved object service itself, we can reuse the validation and utility functions for other database options.


* Cons
* Changes in core Dashboards : We will be making considerable changes in critical component of Dashboards.
* With this approach, user will have to use the data storage option that we choose.
<br/>

**POC**: https://github.com/bandinib-amzn/OpenSearch-Dashboards/compare/main...22d7f30

## Implementation Details


| Repository | Component | Change |
| ----------- | ----------- | ----------- |
| OpenSearch-Dashboards | Saved Object Service | Add Saved object repository factory provider |
| OpenSearch-Dashboards | Config | Configuration for metadata storage |
| MetaStorage-Plugin [Name TBD] | Plugin / Extension | We will build new plugin for Postgres. This is use case for new interface in Saved Object Repository. |

### Configuration for metadata storage:
```
metaStorage.enabled: true
metaStorage.config: {
type: 'xxxx',
hostName: 'xxxx',
userName: 'xxxx',
password: 'xxxx',
port: xxxx,
}
```

## Testing and Quality Assurance

### Testing Approach

The following testing approach will be used to ensure the quality of the system:

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.
2. **Integration testing**: Components will be integrated and tested together to ensure they work together seamlessly and without conflicts.

Loading

0 comments on commit 6b8a820

Please sign in to comment.