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

createCluster requires a partial elasticsearch config #40405

Merged

Conversation

mshustov
Copy link
Contributor

@mshustov mshustov commented Jul 5, 2019

Summary

CreateCluster interface requires passing the whole elasticsearch config as a parameter which leads to leaking elasticsearch config outside of the service. At the same time, the current implementation already relies on partial config:
https://github.com/restrry/kibana/blob/a22349a8bf320a88e19f861ccbf0fd3f30eddf68/src/legacy/core_plugins/elasticsearch/index.js#L83-L86
PR shouldn't change behavior, but make the function interface more convenient to use.

Checklist

Use strikethroughs to remove checklist items you don't feel are applicable to this PR.

For maintainers

@elasticmachine
Copy link
Contributor

💔 Build Failed

@mshustov mshustov force-pushed the eleasticseach-create-cluster-partial-config branch from 900f666 to b2c378a Compare July 8, 2019 09:24
@mshustov mshustov force-pushed the eleasticseach-create-cluster-partial-config branch from b2c378a to 6ea0cb7 Compare July 8, 2019 09:24
@@ -28,7 +28,7 @@ import { Logger } from '../logging';
import { ElasticsearchConfig } from './elasticsearch_config';

/**
* @internalremarks Config that consumers can pass to the Elasticsearch JS client is complex and includes
* @privateRemarks Config that consumers can pass to the Elasticsearch JS client is complex and includes
Copy link
Contributor Author

Choose a reason for hiding this comment

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

* We fill all the missing properties in the `clientConfig` using the default
* Elasticsearch config so that we don't depend on default values set and
* controlled by underlying Elasticsearch JS client.
* We don't run validation against passed config expect it to be valid.
Copy link
Contributor Author

@mshustov mshustov Jul 8, 2019

Choose a reason for hiding this comment

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

We should add validation eventually

createClient: (type: string, clientConfig: ElasticsearchClientConfig) => {
return this.createClusterClient(type, clientConfig, deps.http.auth.getAuthHeaders);
createClient: (type: string, clientConfig: Partial<ElasticsearchClientConfig> = {}) => {
const finalConfig = merge({}, config, clientConfig);
Copy link
Contributor Author

Choose a reason for hiding this comment

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

it's not a full equivalent of

{
  ...esConfig,
  ...clientConfig
}

but I'd expect that user may want to re-write only a part of complex ssl config instead of declaring the full version of it.

@elasticmachine
Copy link
Contributor

💚 Build Succeeded

@mshustov mshustov added Feature:New Platform release_note:skip Skip the PR/issue when compiling release notes review Team:Core Core services & architecture: plugins, logging, config, saved objects, http, ES client, i18n, etc v7.4.0 labels Jul 8, 2019
@elasticmachine
Copy link
Contributor

Pinging @elastic/kibana-platform

@mshustov mshustov changed the title [WIP] createCluster created with partial config createCluster requires a partial elasticsearch config Jul 8, 2019
@mshustov mshustov marked this pull request as ready for review July 8, 2019 15:45
@mshustov mshustov requested a review from a team as a code owner July 8, 2019 15:45
Copy link
Contributor

@eliperelman eliperelman left a comment

Choose a reason for hiding this comment

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

LGTM

@mshustov mshustov merged commit 9920c87 into elastic:master Jul 9, 2019
@mshustov mshustov deleted the eleasticseach-create-cluster-partial-config branch July 9, 2019 18:49
mshustov added a commit to mshustov/kibana that referenced this pull request Jul 9, 2019
* createCluster created with partial config

* add tests

* re-genereate docs
mshustov added a commit that referenced this pull request Jul 9, 2019
* createCluster created with partial config

* add tests

* re-genereate docs
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backported Feature:New Platform release_note:skip Skip the PR/issue when compiling release notes Team:Core Core services & architecture: plugins, logging, config, saved objects, http, ES client, i18n, etc v7.4.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants