-
Notifications
You must be signed in to change notification settings - Fork 8.3k
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
Don't expose Elasticsearch client as Observable #53824
Don't expose Elasticsearch client as Observable #53824
Conversation
Pinging @elastic/kibana-platform (Team:Platform) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Security/Spaces changes LGTM.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This seems definitely better in term of developer experience.
this.adminClient = await core.elasticsearch.adminClient$.pipe(first()).toPromise(); | ||
this.adminClient = core.elasticsearch.adminClient; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Proof by usage that the PR was needed.
createSetupContract: createSetupContractMock, | ||
createInternalSetup: createInternalSetupContractMock, | ||
createSetup: createSetupContractMock, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think I'm in favor of this 'new' naming without the contract
suffix, however this is inconsistent with every other service mocks we got. Should we decide to go with this and change the others when we can?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we should unify this naming. Right now we have inconsistency across the codebase. example
Should we add this to NP conventions and fix all the mocks?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is minor, but I think we should
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
created #54229
async callAsCurrentUser( | ||
endpoint: string, | ||
clientParams: Record<string, any> = {}, | ||
options?: CallAPIOptions | ||
) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
NIT: does explicitly typing the clients to IClusterClient
avoid to redefine the callAsXXXUser
parameter types?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nope. TS complaints Parameter '...' implicitly has an 'any' type
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
😞
it('returns data and admin client as a part of the contract', async () => { | ||
const mockAdminClusterClientInstance = elasticsearchServiceMock.createClusterClient(); | ||
const mockDataClusterClientInstance = elasticsearchServiceMock.createClusterClient(); | ||
MockClusterClient.mockImplementationOnce( | ||
() => mockAdminClusterClientInstance | ||
).mockImplementationOnce(() => mockDataClusterClientInstance); | ||
|
||
const setupContract = await elasticsearchService.setup(deps); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we have any reasons to keep this now? (the filter I mean. Comment is unrelated to the actual test file)
kibana/src/core/server/elasticsearch/elasticsearch_service.ts
Lines 61 to 68 in bde2895
filter(() => { | |
if (this.subscription !== undefined) { | |
this.log.error('Clients cannot be changed after they are created'); | |
return false; | |
} | |
return true; | |
}), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As I understand, our code is ready for runtime config updates, but we don't have such requirements at the moment.
💚 Build SucceededHistory
To update your PR or re-run it, just comment with: |
* expose ES clients without observables * expose observable-less api to plugins * update core api and mocks * update plugins * NP SO & legacy use updated API * update SO tests * update TSDocs * update types * update docs * document createCluster analog in np * typo
* expose ES clients without observables * expose observable-less api to plugins * update core api and mocks * update plugins * NP SO & legacy use updated API * update SO tests * update TSDocs * update types * update docs * document createCluster analog in np * typo
* master: (55 commits) [ui/public/utils] Copy rarely used items to where they are consumed (elastic#53819) set AppArch team as an owner of the search endpoints (elastic#54131) Don't expose Elasticsearch client as Observable (elastic#53824) [SIEM] Cleanup unnecessary use of enzyme-to-json (elastic#53980) fix ui exports doc (elastic#54138) change markdown element title (elastic#54194) [Logs UI] Refactor log position to hooks (elastic#53540) [SIEM] Implement NP Plugin Setup (elastic#54030) [DOCS] Updates ML links (elastic#53613) sort renovate packages in config Spaces - fix flakey api tests (elastic#54154) Remove dependency that was causing effect to re-execute infinitely. (elastic#54160) [dev/run] expose unexpected flags as more than just names (elastic#54080) [DOCS] Moves index pattern doc to Discover (elastic#53347) [SIEM] Cleanup React imports (elastic#53981) Update eslint related packages (elastic#54107) [Uptime] Added date range filter into expanded list query (elastic#52609) [SIEM] Add react/display-name eslint rule (elastic#53107) [SIEM] Enable eslint prefer-template rule (elastic#53983) Elasticsearch snapshots automation (elastic#53706) ...
….com:mbondyra/kibana into IS-50036_show-sum-for-a-field-with-formatter * 'IS-50036_show-sum-for-a-field-with-formatter' of github.com:mbondyra/kibana: [Telemetry] Fix license page crashing on telemetry.enabled: fa… (elastic#54174) [ui/public/utils] Copy rarely used items to where they are consumed (elastic#53819) set AppArch team as an owner of the search endpoints (elastic#54131) Don't expose Elasticsearch client as Observable (elastic#53824) [SIEM] Cleanup unnecessary use of enzyme-to-json (elastic#53980)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry for the late review :(
Oh ignore me, I missed the kibana/src/core/server/elasticsearch/elasticsearch_service.ts Lines 90 to 92 in 56041f0
|
Summary
Closes #53267
TODO:
see related discussion in the parent task.
Checklist
Use
strikethroughsto remove checklist items you don't feel are applicable to this PR.[ ] This was checked for cross-browser compatibility, including a check against IE11[ ] Any text added follows EUI's writing guidelines, uses sentence case text and includes i18n support[ ] This was checked for keyboard-only and screenreader accessibilityFor maintainers
Dev docs
Elasticsearch clients aren't exposed via the Observable interface anymore. Elasticsearch client provides a static API that handles all elasticsearch config updates under the hood, transparent to the end-user.