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

[POC] init impl to add datasource service/client lifecycle #19

Merged
merged 3 commits into from
Jul 22, 2022

Conversation

zhongnansu
Copy link

@zhongnansu zhongnansu commented Jul 20, 2022

Description

  • Add dataSourceClient
    • a map dataSourceClientsPool
    • a flag that maps to global feature flag in osd.yml
    • asDataSource() to find/create client, then return to caller
  • Add opensearch_data_service
    • depends on savedObject service to init a savedObjectClient
    • init DataSourceClient instance
  • Register opensearch_data_service to CoreSetup, CoreStart, CoreRouteHandlerContext
  • Refactor search_source to add dataSourceId field, and add it to ISearchOptions to provide to search() interface
  • Refactor opensearchagg.ts, to attach data source id if exists
  • Refactor opensearch_seearch_strategy to select between default cluster client and data source client

TODO

  • See comment for more. The critical TODOs for the end-to-end use case to run are:
    • Align with the data modeling of index pattern and dataSource, pending PR from @kristenTian

Test

Only manual test for now
Steps:

  1. add ecommerce sample data
  2. delete its index
  3. create a valid datasource and credential
  4. Manually attach dataSourceId to ecommerce index pattern by something like:
POST /.kibana/_update/index-pattern:ff959d40-b880-11e8-a6d9-e546fe2bba5f
{
"script": "ctx._source['index-pattern'].dataSourceId = '794b5590-088b-11ed-8694-134ac2453186'"
}
  1. Now you should be able to see a ecommerce visualization with the data from data source
  2. Discover/TSVB/Vega/Timelion is not working for now, I'll post other PRs to address those.

Issues Resolved

TBA

Check List

  • New functionality includes testing.
    • All tests pass
      • yarn test:jest
      • yarn test:jest_integration
      • yarn test:ftr
  • New functionality has been documented.
  • Commits are signed per the DCO using --signoff

@zhongnansu zhongnansu changed the title init commit to add datasource client lifecycle init commit to add datasource service/client lifecycle Jul 20, 2022
@zhongnansu zhongnansu marked this pull request as ready for review July 20, 2022 23:46
const url = dataSourceObj.endpoint.url;
/**
* TODO:
* credential manager will provide "decrypt(authId: string)" to return auth

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@noCharger do we have action item for this.

Copy link
Collaborator

@noCharger noCharger Jul 21, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add Decrypt function

As discussed offline, we can use https://github.com/elastic-analytics/OpenSearch-Dashboards/blob/db8c74eacd7a78830f[…]c/plugins/credential_management/server/crypto/cli/crypto_cli.ts for the end-to-end PoC. Support decrypt(authId: string) is a non-blocking follow-up.

Also from the principle of single responsibility, fetch credential using saved object cli and decrypt with cryto cli could be decoupled. Let's name the function as fetch_and_decrypt(id: string)

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@noCharger do we have action item for this.

opensearch-project#1926

Copy link
Author

@zhongnansu zhongnansu Jul 21, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@noCharger Made the change to first fetch encrypted password in opensearch_data_service, and then use existing CrptoCLI -> decrypt() function for the end-to-end use case to run. Any subsequent change will be posted in separate PR. But I don't think a functionality of getCredentialById is a multi-responsibility. We can discuss more

@seraphjiang
Copy link

Please add one TODO:

pick up one viz to demonstrate usage of the new data source client.

@zhongnansu zhongnansu changed the title init commit to add datasource service/client lifecycle [not ready to merge]init commit to add datasource service/client lifecycle Jul 21, 2022
@zhongnansu zhongnansu changed the title [not ready to merge]init commit to add datasource service/client lifecycle [POC] init impl to add datasource service/client lifecycle Jul 21, 2022
@zhongnansu
Copy link
Author

Please add one TODO:

pick up one viz to demonstrate usage of the new data source client.

@seraphjiang End to end use case verified. Steps added to the PR description

Copy link

@zengyan-amazon zengyan-amazon left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

do not commit yarn.lock

}
async asDataSource(dataSourceId: string) {
const { endpoint, credentialId } = await this.getDataSourceInfo(dataSourceId);
const { username, password } = await this.getCredentialInfo(credentialId);

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

need to consider more auth types

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What's are the current defined auth type in data source data model or credential manager? @kristenTian @noCharger

}

// close anything in pool
public async close() {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please check the opensearch js client, see if it can keep the connection until being explicitly closed

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

private readonly log: Logger;
private readonly config$: Observable<OpenSearchConfig>;
private auditorFactory?: AuditorFactory;
private stop$ = new Subject();

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

how is this field being used?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it's used in the Compatibility check(that I commented out for now). Compatibility checks happen constantly until "this.stop" is called (which it will be called in stop() stage in our case)

src/plugins/data/server/saved_objects/index_patterns.ts Outdated Show resolved Hide resolved
@zhongnansu zhongnansu force-pushed the search-source-poc branch 2 times, most recently from 7c33c9d to 7f0bfa3 Compare July 22, 2022 02:22
@zhongnansu
Copy link
Author

do not commit yarn.lock

removed

@zhongnansu zhongnansu merged commit 4994527 into 2.x Jul 22, 2022
noCharger added a commit that referenced this pull request Jul 22, 2022
… on osd.yml (#18)

1. Move generate_crypto_materials to /script
2. Add cm configs to osd.yml
3. Add multipleDataSource global configuration support to osd.yml
4. Create default crypto material during plugin setup
5. Fix merge issues from #19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants