-
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
[ES] Upgrade client to v8.0 #113950
[ES] Upgrade client to v8.0 #113950
Conversation
…sts/actions.test.ts
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.
LGTM,
- Looked through the
security_solution
code, saw most was repeating patterns for the upgrade. - Took two notes of an areas that looked more involved, dug a bit deeper but those areas look ok to me 👍
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.
Asset management 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.
infra
plugin changes LGTM. We'll do some cleanup separately. Thank you!
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.
Approving for @elastic/metrics-ui and @elastic/stack-monitoring-ui
…issue-108387-es-client-80
…egistered by home
💛 Build succeeded, but was flaky
Test Failures
Metrics [docs]Public APIs missing comments
Async chunks
Public APIs missing exports
Unknown metric groupsAPI count
History
To update your PR or re-run it, just comment with: |
Summary
Migrates Kibana to next major version of the
@elastic/elasticsearch
clientcloses #108387
The full list of changes is here
Some most noticeable changes:
The returned value of API calls is the body and not the HTTP related keys.
It's the biggest source of changes in the current PR. From
v8.0
, the Client will returnbody
by default. If you needstatusCode
andheader
, you need to providemeta: true
flag toTransportRequestOptions
Since this change affected literally every method call in the entire repository, we decided that the service provided from Core would default to this
meta: true
flag of of the box.This creates a difference in the
import type { Client } from '@elastic/elasticsearch'
andimport type { ElasticsearchClient } from 'src.core.server
client interfaces, so I've created #116095 to resolve these differences.Your plugin code doesn't need to set this flag manually.
The code in your functional tests can set the flag. it depends on whether you need meta-information about the request results.
Types for the mode with
meta: true
should be imported from@elastic/elasticsearch/lib/api/typesWithBodyKey
.Drop support for old camelCased keys
Some interfaces have been removed in #115528, some in the current PR.
Remove the current abort API and use the new Abort API
Code in
data
andAPM
plugins is refactored.body
key inrequest
is derecated.Codeowner should inline body keys instead. We will define an explicit deadline to remove the
body
key from requests.Some request keys have been renamed
Use type definitions as the reference.
Product check performed on every response
Notes for teams
createEsClient
inferred type, I kindly ask you to fix it in a follow-up@ts-ignore
since type check fails locally and on CI unpredictablySkipped tests
x-pack/test/search_sessions_integration/tests/apps/discover/async_search.ts
kibana/x-pack/test/search_sessions_integration/tests/apps/discover/async_search.ts
Lines 105 to 108 in 0a615cb
Performance
DemoJourney test shows "global" response time reduced by 30%The performance will be improved when we switch to the new http client (undici). The HTTP client migration will be done in a separate task #116087
Known problems with Kibana
KibanaClient
because KibanaClient enforcesmeta:true
kibana still relies on removedindices.freeze
functionalityList of known client problems
body
is rewritten by any parameter https://github.com/elastic/elasticsearch-js/blob/main/src/api/api/create.ts#L56-L59 probably another API is broken too'node-abort-controller'
doesn't contain typingsundici
usesbuffer
API introduced in nodejs v15.@elastic/transport
typings, I had to add@elastic/transport
to the Kibana depsClient
is not compatible withKibanaClient
('dataFrameTransformDeprecated' is missing in type 'Client')statusCode
,body
andheaders
are optional inDiagnosticResult
Client usesSymbol
to declare API. It breaks mocks in Kibanasignal: AbortSignal
instead. See examples https://www.npmjs.com/package/node-abort-controller https://www.npmjs.com/package/node-fetch#request-cancellation-with-abortsignal{ [key:string]: never }
: MappingFieldMapping, IndicesUpdateAliasesIndicesUpdateAliasBulk, IlmAction, Transform, AggregationsBucketsPath, SpecUtilsAdditionalProperties, SpecUtilsAdditionalProperty, SpecUtilsOverloadOf, SearchAggregationProfileDebug, AggregationsPercentageScoreHeuristic, QueryDslRankFeatureFunction, QueryDslRankFeatureFunctionLinear, WatcherAlwaysCondition, WatcherNeverConditionstring
instead.Context
should falls back tounknown
by deafult. Otherwise we have to explicitly declaretype My = TransportResult<ResponseType, unknown>
instead oftype My = TransportResult<ResponseType>
. It affectsDiagnosticResult
as well.SearchHitsMetadata.total
should it beSearchTotalHits
? AFAIKnumber
is deprecatedenum
for events. It's better to use a method overload instead of importingenum
.client.diagnostic.on(events.RESPONS
-->client.diagnostic.on('response')
keepAlive
andmaxSockets
optionsRequestBody
and others aren't exported from@elastic/transport/lib/types
BulkResponseItemBase.error: ErrorCause | string;
,MgetHit.error: ErrorCause | string;
,ShardFailure.reason: ErrorCause | string;
and lots of others break a lot of code since it doesn't expectstring
@elastic/transport
directlyilm.putLifecycle({ policy, body })
fails with ES errorResponseError: x_content_parse_exception: [x_content_parse_exception] Reason: [1:11] [put_lifecycle_request] policy doesn't support values of type: VALUE_STRING
butilm.putLifecycle({ body })
fails with ES client errorTypeError: Cannot read property 'toString' of undefined at Ilm.putLifecycle (/@elastic/elasticsearch/src/api/api/ilm.ts:245:67)
body
https://github.com/elastic/elasticsearch-js/blob/main/src/api/api/transform.ts#L228scroll({body: { scroll_id:.. } })
fails intil move body to params:scroll({ scroll_id:.. })
indices.freeze
methodcomptible-with=8
toaccept
header, but notcontent-type
ml.startDatafeed
request do not recognizestart
ConnectionError: path must be an absolute URL or start with a slash
sort
param is always sent in the body. ThefieldName:sortOrder
syntax can no longer be used (e.gsort: 'create_at:desc'
)packages/kbn-apm-config-loader/src/init_apm.ts
packages/kbn-apm-config-loader/src/init_apm.test.ts
x-pack/test/performance/tests/reporting_dashboard.ts
Risk Matrix
Plugin API changes
Elasticsearch service provides the new version of the
elasticsearch-js
library. You can find the full list of changes, including breaking ones, here.