Skip to content
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

[NodeJS] Dashboards is not compatible with nodejs client #837

Closed
8 tasks done
ananzh opened this issue Oct 1, 2021 · 0 comments · Fixed by #1342
Closed
8 tasks done

[NodeJS] Dashboards is not compatible with nodejs client #837

ananzh opened this issue Oct 1, 2021 · 0 comments · Fixed by #1342
Assignees
Labels
nodejs 🍭 issues related to nodejs client v2.0.0

Comments

@ananzh
Copy link
Member

ananzh commented Oct 1, 2021

Tasks

Describe the bug

We forked nodejs client (repo here) from v7.14 and delete all the non-oss api between v7.10 to v7.14. nodejs client v7.14 is not compatible with current Dashboards due to type change.

For example, below is the indices.get defined in nodejs v7.14:

get<TContext = unknown>(params: T.IndicesGetRequest, options?: TransportRequestOptions): TransportRequestPromise<ApiResponse<T.IndicesGetResponse, TContext>>

which is different from its definition in nodejs v7.10:

get<TResponse = Record<string, any>, TContext = Context>(params?: RequestParams.IndicesGet, options?: TransportRequestOptions): TransportRequestPromise<ApiResponse<TResponse, TContext>>

If we refers to @opensearch-project/opensearch and change all the client from KibanaClient to OpenSearchDashboardsClient, we could see type undefined errors from bootstrap. Below is one example:

ERROR [bootstrap] failed:
ERROR Error: Command failed with exit code 1: /usr/share/yarn/bin/yarn.js run osd:bootstrap
      error Command failed with exit code 1.
      $ node scripts/build_ts_refs && node scripts/register_git_hook
      ERROR Error: Command failed with exit code 1: /home/anan/work/OpenSearch-Dashboards/node_modules/typescript/bin/tsc -b tsconfig.refs.json --pretty
            src/core/server/saved_objects/migrations/core/opensearch_index.ts:71:33 - error TS2345: Argument of type '{ exists: true; indexName: string; aliases?: Record<string, IndicesAlias> | undefined; mappings?: MappingTypeMapping | undefined; settings: IndicesIndexSettings | IndicesIndexStatePrefixedSettings; }' is not assignable to parameter of type 'FullIndexInfo'.
              Types of property 'aliases' are incompatible.
                Type 'Record<string, IndicesAlias> | undefined' is not assignable to type '{ [name: string]: object; }'.
                  Type 'undefined' is not assignable to type '{ [name: string]: object; }'.

            71   return assertIsSupportedIndex({ ...indexInfo, exists: true, indexName });
                                               ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

To Reproduce
1)yarn add @opensearch-project/opensearch
2) search @elastic/elasticsearch in non package.json files and replace it with @opensearch-project/opensearch
3) go to src/core/server/saved_objects/migrations/core/opensearch_index.ts change KibanaClient to OpenSearchDashboardsClient

Impact to Plugins

The major change brought by new opensearch-js client is that the api types are looser ( here ) than the original ( here ) . For example, comparing how bulk api is previously defined as

bulk<TResponse = Record<string, any>, TRequestBody extends RequestNDBody = Record<string, any>[], TContext = Context>(params?: RequestParams.Bulk<TRequestBody>, options?: TransportRequestOptions): TransportRequestPromise<ApiResponse<TResponse, TContext>> 

While in the new.d.ts, the bulk api is now changed to:

bulk<TSource = unknown, TContext = unknown>(params: T.BulkRequest<TSource>, options?: TransportRequestOptions): TransportRequestPromise<ApiResponse<T.BulkResponse, TContext>>

Since it is a looser typed client, we don’t see much breaking changes in the dashboards code base. Most changes are related to type fixes which should not affect plugin owners. For most plugins, they use client interact with data plugin. For index management plugin, it uses Client defined in /src/core/server/opensearch/legacy. Though this client is imported from 'elasticsearch' but this is actually "@types/elasticsearch": "^5.0.33" from here. Currently, we don’t plan to change the legacy server and client.

To sum up, we don’t see breaking changes for plugins. I listed some steps to try using anomaly-detection below. SInce we are still fixing the PRs, could try with my test branch. However, since none of the plugins are using opensearch/opensearch-dashboards 2.0 or bump the node&package version accordingly, it is hard to evaluate the full impact. I would highly suggest that plugins bump to version 2.0 with node v14 and upgraded packages. Use the below steps to hook up with the opensearch-dashboards. Run all the unit tests, integration tests, and sanity tested the plugin.

Anomaly Detection build & run steps

  1. Use OpenSearch main branch (v2.0). Fork and Clone anomaly-detection backend plugin (https://github.com/opensearch-project/anomaly-detection)
  2. run ./gradlew build in anomaly-detection directory
  3. run ./gradlew :run to run a single node cluster with anomaly-detection plugin
  4. Fork and clone anomaly-detection-dashboards-plugin (https://github.com/opensearch-project/anomaly-detection-dashboards-plugin) into the <rootDir>/plugins for OpenSearch Dashboards with the nodejs client hooked up
  5. make sure to use node 14.18.2 and run yarn osd bootstrap inside of OpenSearch Dashboards <rootDir>
  6. update "opensearchDashboardsVersion" in <rootDir>/plugins/anomaly-detection-dashboards-plugin/opensearch_dashboards.json from "1.3.0" to "2.0.0"
  7. update <rootDir>/config/opensearch_dashboards.yml and add "openserch.ignoreVersionMismatch: true" in this config file. This is because plugin is still using v1.3.0 while dashboards is v2.0.0. This line will ignore the version mismatch check ( ).
  8. run yarn start inside of OpenSearch Dashboards and verify anomaly-detection plugin is running up
  9. run tests and play with anomaly-detection plugin

Running anomaly-detection:
Screen Shot 2022-03-02 at 11 31 37 PM

Unit test results:
Screen Shot 2022-03-02 at 11 33 48 PM

Integration test results:
Screen Shot 2022-03-02 at 11 59 37 PM

Screen Shot 2022-03-03 at 12 01 55 AM

Screen Shot 2022-03-03 at 12 07 16 AM

Expected behavior
Update Dashboards in 2.0 with type changes

OpenSearch Version
2.0

Dashboards Version
2.0

Plugins
plugins also need to update the types

@ananzh ananzh added the v2.0.0 label Oct 1, 2021
@kavilla kavilla changed the title Dashboards is not compatible with nodejs client [OSJS] Dashboards is not compatible with nodejs client Jan 5, 2022
@kavilla kavilla changed the title [OSJS] Dashboards is not compatible with nodejs client [NodeJS] Dashboards is not compatible with nodejs client Jan 11, 2022
@kavilla kavilla added the nodejs 🍭 issues related to nodejs client label Jan 11, 2022
ananzh added a commit to ananzh/OpenSearch-Dashboards that referenced this issue Jan 27, 2022
change @elastic/elasticsearch to @opensearch-project/opensearch

Partically Resolved: opensearch-project#837

Signed-off-by: Anan Zhuang <[email protected]>
ananzh added a commit that referenced this issue Jan 27, 2022
change @elastic/elasticsearch to @opensearch-project/opensearch

Partically Resolved: #837

Signed-off-by: Anan Zhuang <[email protected]>
ananzh added a commit to ananzh/OpenSearch-Dashboards that referenced this issue Jan 27, 2022
change @elastic/elasticsearch to @opensearch-project/opensearch

Partically Resolved: opensearch-project#837

Signed-off-by: Anan Zhuang <[email protected]>
ananzh added a commit that referenced this issue Jan 27, 2022
change @elastic/elasticsearch to @opensearch-project/opensearch

Partically Resolved: #837

Signed-off-by: Anan Zhuang <[email protected]>
ananzh added a commit to ananzh/OpenSearch-Dashboards that referenced this issue Feb 7, 2022
1.import Client from '@opensearch-project/opensearch/api/new' to hook
up the new types
2.add support functions. for example, add a support function for
converting a possibly not existant doc to an existant doc.
3.add @ts-expect-error to expected mismatches
4.fix undefined and mismatched types
5.fix unit tests in src/core/server/saved_objects

Issue Resolved: opensearch-project#1216
Partical Resolved: opensearch-project#837

Signed-off-by: Anan Zhuang <[email protected]>
ananzh added a commit to ananzh/OpenSearch-Dashboards that referenced this issue Feb 7, 2022
1. import Client from '@opensearch-project/opensearch/api/new' to hook
up the new types
2. remove asynSearch
3. apply type assertion
4. fix undefined and mismatched types

Remove retry_call_cluster.test.ts due to removing all asyncSearch api

Issue Resolved: opensearch-project#1193
Partical Resolved: opensearch-project#837
Signed-off-by: Anan Zhuang <[email protected]>
ananzh added a commit to ananzh/OpenSearch-Dashboards that referenced this issue Feb 8, 2022
1.import Client from '@opensearch-project/opensearch/api/new' to hook
up the new types
2.add support functions. for example, add a support function for
converting a possibly not existant doc to an existant doc.
3.add @ts-expect-error to expected mismatches
4.fix undefined and mismatched types
5.fix unit tests in src/core/server/saved_objects

Issue Resolved: opensearch-project#1216
Partical Resolved: opensearch-project#837

Signed-off-by: Anan Zhuang <[email protected]>
ananzh added a commit to ananzh/OpenSearch-Dashboards that referenced this issue Feb 8, 2022
1.import Client from '@opensearch-project/opensearch/api/new' to hook
up the new types
2.add support functions. for example, add a support function for
converting a possibly not existant doc to an existant doc.
3.add @ts-expect-error to expected mismatches
4.fix undefined and mismatched types
5.fix unit tests in src/core/server/saved_objects

Issue Resolved: opensearch-project#1216
Partical Resolved: opensearch-project#837

Signed-off-by: Anan Zhuang <[email protected]>
ananzh added a commit to ananzh/OpenSearch-Dashboards that referenced this issue Feb 8, 2022
…service.ts

Fix issues in src/core/server/core_usage_data_service.ts.
Change types of property docsCount,docsDeleted,storeSizeBytes
and primaryStoreSizeBytes from 'string | undefined to 'number'.

Issue Resolved: opensearch-project#1224
Partical Resolved: opensearch-project#837

Signed-off-by: Anan Zhuang <[email protected]>
ananzh added a commit to ananzh/OpenSearch-Dashboards that referenced this issue Feb 17, 2022
ananzh added a commit to ananzh/OpenSearch-Dashboards that referenced this issue Feb 17, 2022
ananzh added a commit to ananzh/OpenSearch-Dashboards that referenced this issue Feb 17, 2022
add path in tsconfig.base.json to let nodejs types point to api/new.d.ts
which is the new defined types

Partially Resolved:opensearch-project#837

Signed-off-by: Anan Zhuang <[email protected]>
ananzh added a commit that referenced this issue Feb 17, 2022
1. import Client from '@opensearch-project/opensearch/api/new' to hook
up the new types
2. remove asynSearch
3. apply type assertion
4. fix undefined and mismatched types

Remove retry_call_cluster.test.ts due to removing all asyncSearch api

Issue Resolved: #1193
Partical Resolved: #837
Signed-off-by: Anan Zhuang <[email protected]>
ananzh added a commit to ananzh/OpenSearch-Dashboards that referenced this issue Feb 17, 2022
1.import Client from '@opensearch-project/opensearch/api/new' to hook
up the new types
2.add support functions. for example, add a support function for
converting a possibly not existant doc to an existant doc.
3.add @ts-expect-error to expected mismatches
4.fix undefined and mismatched types
5.fix unit tests in src/core/server/saved_objects

Fix comments and modify import types

Issue Resolved: opensearch-project#1216
Partical Resolved: opensearch-project#837

Signed-off-by: Anan Zhuang <[email protected]>
ananzh added a commit to ananzh/OpenSearch-Dashboards that referenced this issue Feb 23, 2022
ananzh added a commit that referenced this issue Feb 28, 2022
add path in tsconfig.base.json to let nodejs types point to api/new.d.ts
which is the new defined types

Partially Resolved:#837

Signed-off-by: Anan Zhuang <[email protected]>
ananzh added a commit to ananzh/OpenSearch-Dashboards that referenced this issue Feb 28, 2022
…1181)

change @elastic/elasticsearch to @opensearch-project/opensearch

Partically Resolved: opensearch-project#837

Signed-off-by: Anan Zhuang <[email protected]>
ananzh added a commit to ananzh/OpenSearch-Dashboards that referenced this issue Feb 28, 2022
ananzh added a commit to ananzh/OpenSearch-Dashboards that referenced this issue Feb 28, 2022
Native realm is not supported by current nodejs client.

Partically Resolved:opensearch-project#837

Signed-off-by: Anan Zhuang <[email protected]>
ananzh added a commit that referenced this issue Mar 2, 2022
…service.ts (#1225)

Fix issues in src/core/server/core_usage_data_service.ts.
Change types of property docsCount,docsDeleted,storeSizeBytes
and primaryStoreSizeBytes from 'string | undefined to 'number'.

Issue Resolved: #1224
Partical Resolved: #837

Signed-off-by: Anan Zhuang <[email protected]>
ananzh added a commit to ananzh/OpenSearch-Dashboards that referenced this issue Mar 2, 2022
Native realm is not supported by current nodejs client.

Partically Resolved:opensearch-project#837

Signed-off-by: Anan Zhuang <[email protected]>
ananzh added a commit to ananzh/OpenSearch-Dashboards that referenced this issue Mar 2, 2022
Native realm is not supported by current nodejs client.
This will solve nodejs client integration issue.

Partically Resolved:opensearch-project#837

Signed-off-by: Anan Zhuang <[email protected]>
ananzh added a commit to ananzh/OpenSearch-Dashboards that referenced this issue Mar 2, 2022
1.import Client from '@opensearch-project/opensearch/api/new' to hook
up the new types
2.add support functions. for example, add a support function for
converting a possibly not existant doc to an existant doc.
3.add @ts-expect-error to expected mismatches
4.fix undefined and mismatched types
5.fix unit tests in src/core/server/saved_objects

Fix comments and modify import types
Remove require_alias
remove coreMigrationVersion to avoid bwc issue

Issue Resolved: opensearch-project#1216
Partical Resolved: opensearch-project#837

Signed-off-by: Anan Zhuang <[email protected]>

modify repository

Signed-off-by: Anan Zhuang <[email protected]>
ananzh added a commit that referenced this issue Mar 3, 2022
Native realm is not supported by current nodejs client.
This will solve nodejs client integration issue.

Partically Resolved:#837

Signed-off-by: Anan Zhuang <[email protected]>
Tengda-He pushed a commit to Tengda-He/OpenSearch-Dashboards that referenced this issue Mar 3, 2022
Native realm is not supported by current nodejs client.
This will solve nodejs client integration issue.

Partically Resolved:opensearch-project#837

Signed-off-by: Anan Zhuang <[email protected]>
ananzh added a commit to ananzh/OpenSearch-Dashboards that referenced this issue Mar 4, 2022
1.import Client from '@opensearch-project/opensearch/api/new' to hook
up the new types
2.add support functions. for example, add a support function for
converting a possibly not existant doc to an existant doc.
3.add @ts-expect-error to expected mismatches
4.fix undefined and mismatched types
5.fix unit tests in src/core/server/saved_objects

Fix comments and modify import types
Remove require_alias
remove coreMigrationVersion to avoid bwc issue
modify repository
add param comments

Issue Resolved: opensearch-project#1216
Partical Resolved: opensearch-project#837

Signed-off-by: Anan Zhuang <[email protected]>
ananzh added a commit that referenced this issue Mar 4, 2022
…1223)

1.import Client from '@opensearch-project/opensearch/api/new' to hook
up the new types
2.add support functions. for example, add a support function for
converting a possibly not existant doc to an existant doc.
3.add @ts-expect-error to expected mismatches
4.fix undefined and mismatched types
5.fix unit tests in src/core/server/saved_objects

Fix comments and modify import types
Remove require_alias
remove coreMigrationVersion to avoid bwc issue
modify repository
add param comments

Issue Resolved: #1216
Partical Resolved: #837

Signed-off-by: Anan Zhuang <[email protected]>
ananzh added a commit that referenced this issue Mar 5, 2022
change @elastic/elasticsearch to @opensearch-project/opensearch

Partically Resolved: #837

Signed-off-by: Anan Zhuang <[email protected]>
ananzh added a commit that referenced this issue Mar 5, 2022
1. import Client from '@opensearch-project/opensearch/api/new' to hook
up the new types
2. remove asynSearch
3. apply type assertion
4. fix undefined and mismatched types

Remove retry_call_cluster.test.ts due to removing all asyncSearch api

Issue Resolved: #1193
Partical Resolved: #837
Signed-off-by: Anan Zhuang <[email protected]>
ananzh added a commit that referenced this issue Mar 5, 2022
add path in tsconfig.base.json to let nodejs types point to api/new.d.ts
which is the new defined types

Partially Resolved:#837

Signed-off-by: Anan Zhuang <[email protected]>
ananzh added a commit that referenced this issue Mar 5, 2022
…service.ts (#1225)

Fix issues in src/core/server/core_usage_data_service.ts.
Change types of property docsCount,docsDeleted,storeSizeBytes
and primaryStoreSizeBytes from 'string | undefined to 'number'.

Issue Resolved: #1224
Partical Resolved: #837

Signed-off-by: Anan Zhuang <[email protected]>
ananzh added a commit that referenced this issue Mar 5, 2022
…1223)

1.import Client from '@opensearch-project/opensearch/api/new' to hook
up the new types
2.add support functions. for example, add a support function for
converting a possibly not existant doc to an existant doc.
3.add @ts-expect-error to expected mismatches
4.fix undefined and mismatched types
5.fix unit tests in src/core/server/saved_objects

Fix comments and modify import types
Remove require_alias
remove coreMigrationVersion to avoid bwc issue
modify repository
add param comments

Issue Resolved: #1216
Partical Resolved: #837

Signed-off-by: Anan Zhuang <[email protected]>
ananzh added a commit that referenced this issue Mar 5, 2022
add path in tsconfig.base.json to let nodejs types point to api/new.d.ts
which is the new defined types

Partially Resolved:#837

Signed-off-by: Anan Zhuang <[email protected]>
ananzh added a commit that referenced this issue Mar 5, 2022
1. import Client from '@opensearch-project/opensearch/api/new' to hook
up the new types
2. remove asynSearch
3. apply type assertion
4. fix undefined and mismatched types

Remove retry_call_cluster.test.ts due to removing all asyncSearch api

Issue Resolved: #1193
Partical Resolved: #837
Signed-off-by: Anan Zhuang <[email protected]>
ananzh added a commit that referenced this issue Mar 5, 2022
…service.ts (#1225)

Fix issues in src/core/server/core_usage_data_service.ts.
Change types of property docsCount,docsDeleted,storeSizeBytes
and primaryStoreSizeBytes from 'string | undefined to 'number'.

Issue Resolved: #1224
Partical Resolved: #837

Signed-off-by: Anan Zhuang <[email protected]>
ananzh added a commit that referenced this issue Mar 5, 2022
…1223)

1.import Client from '@opensearch-project/opensearch/api/new' to hook
up the new types
2.add support functions. for example, add a support function for
converting a possibly not existant doc to an existant doc.
3.add @ts-expect-error to expected mismatches
4.fix undefined and mismatched types
5.fix unit tests in src/core/server/saved_objects

Fix comments and modify import types
Remove require_alias
remove coreMigrationVersion to avoid bwc issue
modify repository
add param comments

Issue Resolved: #1216
Partical Resolved: #837

Signed-off-by: Anan Zhuang <[email protected]>
ananzh added a commit to ananzh/OpenSearch-Dashboards that referenced this issue Mar 12, 2022
1.change @elastic/elasticsearch to @opensearch-project/opensearch
2.add path in tsconfig.base.json to let nodejs types point to api/new.d.ts
which is the new defined types
3.fix hookup issues in src/core/server/opensearch
4.fix hookup issues in src/core/server/core_usage_data_service.ts
5.fix hookup issues in src/core/server/saved_objects

Issue Resolved: opensearch-project#1193
Issue Resolved: opensearch-project#1224
Issue Resolved: opensearch-project#1216
Partical Resolved: opensearch-project#837

Signed-off-by: Anan Zhuang <[email protected]>
ananzh added a commit to ananzh/OpenSearch-Dashboards that referenced this issue Mar 12, 2022
1.change @elastic/elasticsearch to @opensearch-project/opensearch
2.add path in tsconfig.base.json to let nodejs types point to api/new.d.ts
which is the new defined types
3.fix hookup issues in src/core/server/opensearch
4.fix hookup issues in src/core/server/core_usage_data_service.ts
5.fix hookup issues in src/core/server/saved_objects

Sub-Issue Resolved: opensearch-project#1193
Sub-Issue Resolved: opensearch-project#1224
Sub-Issue Resolved: opensearch-project#1216
Issue Resolved: opensearch-project#837

Signed-off-by: Anan Zhuang <[email protected]>
ananzh added a commit to ananzh/OpenSearch-Dashboards that referenced this issue Mar 18, 2022
1.change @elastic/elasticsearch to @opensearch-project/opensearch
2.add path in tsconfig.base.json to let nodejs types point to api/new.d.ts
which is the new defined types
3.fix hookup issues in src/core/server/opensearch
4.fix hookup issues in src/core/server/core_usage_data_service.ts
5.fix hookup issues in src/core/server/saved_objects

fix PR comments and add more explains to type mismatch

Sub-Issue Resolved: opensearch-project#1193
Sub-Issue Resolved: opensearch-project#1224
Sub-Issue Resolved: opensearch-project#1216
Issue Resolved: opensearch-project#837

Signed-off-by: Anan Zhuang <[email protected]>
ananzh added a commit to ananzh/OpenSearch-Dashboards that referenced this issue Mar 18, 2022
1.change @elastic/elasticsearch to @opensearch-project/opensearch
2.add path in tsconfig.base.json to let nodejs types point to api/new.d.ts
which is the new defined types
3.fix hookup issues in src/core/server/opensearch
4.fix hookup issues in src/core/server/core_usage_data_service.ts
5.fix hookup issues in src/core/server/saved_objects

fix PR comments and add more explains to type mismatch

Sub-Issue Resolved: opensearch-project#1193
Sub-Issue Resolved: opensearch-project#1224
Sub-Issue Resolved: opensearch-project#1216
Issue Resolved: opensearch-project#837

Signed-off-by: Anan Zhuang <[email protected]>
kavilla pushed a commit that referenced this issue Mar 23, 2022
1.change @elastic/elasticsearch to @opensearch-project/opensearch
2.add path in tsconfig.base.json to let nodejs types point to api/new.d.ts
which is the new defined types
3.fix hookup issues in src/core/server/opensearch
4.fix hookup issues in src/core/server/core_usage_data_service.ts
5.fix hookup issues in src/core/server/saved_objects

fix PR comments and add more explains to type mismatch

Sub-Issue Resolved: #1193
Sub-Issue Resolved: #1224
Sub-Issue Resolved: #1216
Issue Resolved: #837

Signed-off-by: Anan Zhuang <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
nodejs 🍭 issues related to nodejs client v2.0.0
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants