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

Update ES client to 7.16-canary.7 #117305

Merged
merged 34 commits into from
Nov 4, 2021
Merged
Show file tree
Hide file tree
Changes from 32 commits
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
521814b
bump client version
mshustov Nov 3, 2021
16d76be
bump version to canary 6
mshustov Nov 3, 2021
cadb83a
remove unnecesary ts-expect-error in pacakges
mshustov Nov 3, 2021
a02812e
fix errors in src/core
mshustov Nov 3, 2021
59d45ba
fix errors in data_views
mshustov Nov 3, 2021
cba9281
fix errors in actions
mshustov Nov 3, 2021
7534ecd
fix errors in fleet
mshustov Nov 3, 2021
63bab0f
fix errors in ilm
mshustov Nov 3, 2021
129529a
fix errors in index_management
mshustov Nov 3, 2021
8af76c6
mute errors in ML
mshustov Nov 3, 2021
0992cdd
fix errors in transform
mshustov Nov 3, 2021
49c0506
mute errors in infra
mshustov Nov 3, 2021
c27ec73
fix errors in ingest_pipeline
mshustov Nov 3, 2021
3e56d49
fix errors in security_solution
mshustov Nov 3, 2021
d8f7797
fix errors in snapshot_restore
mshustov Nov 3, 2021
59d73c5
fix errors in upgrade_assistant
mshustov Nov 3, 2021
79f6133
fix and mute errors in APM
mshustov Nov 3, 2021
dd4c886
mute errors in license_management
mshustov Nov 3, 2021
41ff668
mute errors in logstash
mshustov Nov 3, 2021
aac441c
mute errors in osquery
mshustov Nov 3, 2021
236c4b9
mute errors in remote clusters
mshustov Nov 3, 2021
e115f08
mute errors in task_manager
mshustov Nov 3, 2021
ab2b58c
mute errors in uptime
mshustov Nov 3, 2021
c901ceb
mute errors in monitoring
mshustov Nov 3, 2021
463c510
mute errors in task_manager
mshustov Nov 3, 2021
aec2c5b
mute errors in triggers_actions_ui
mshustov Nov 3, 2021
e441fe2
fix errors in rule_registry
mshustov Nov 3, 2021
12ee555
fix errors in security
mshustov Nov 3, 2021
b583938
update infra ts-ignore. there are errors on the localhost but no erro…
mshustov Nov 3, 2021
3445114
bump to a version with module resolutioon fix
mshustov Nov 3, 2021
70e1ffc
update test in apm
mshustov Nov 3, 2021
5cd4aaf
remove unnecassry ts-expect-error in kbn-es-query
mshustov Nov 3, 2021
9ad601d
Merge branch '7.16' into update-es-client
kibanamachine Nov 4, 2021
293ea77
Merge branch '7.16' into update-es-client
kibanamachine Nov 4, 2021
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@
"@elastic/apm-rum-react": "^1.3.1",
"@elastic/charts": "38.0.1",
"@elastic/datemath": "link:bazel-bin/packages/elastic-datemath",
"@elastic/elasticsearch": "npm:@elastic/elasticsearch-canary@^7.16.0-canary.4",
"@elastic/elasticsearch": "npm:@elastic/elasticsearch-canary@^7.16.0-canary.7",
"@elastic/ems-client": "7.16.0",
"@elastic/eui": "39.1.2",
"@elastic/filesaver": "1.1.2",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,6 @@ describe('kuery functions', () => {
const node = nodeTypes.function.buildNode('geoBoundingBox', 'geo', params);
const result = geoBoundingBox.toElasticsearchQuery(node, indexPattern);

// @ts-expect-error @elastic/elasticsearch doesn't support ignore_unmapped in QueryDslGeoBoundingBoxQuery
expect(result.geo_bounding_box!.ignore_unmapped).toBe(true);
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,6 @@ export function toElasticsearchQuery(
}

return {
// @ts-expect-error @elastic/elasticsearch doesn't support ignore_unmapped in QueryDslGeoBoundingBoxQuery
geo_bounding_box: {
[fieldName]: queryParams,
ignore_unmapped: true,
Expand Down
1 change: 0 additions & 1 deletion packages/kbn-es-query/src/kuery/functions/geo_polygon.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,6 @@ export function toElasticsearchQuery(
}

return {
// @ts-expect-error @elastic/elasticsearch doesn't support ignore_unmapped in QueryDslGeoPolygonQuery
geo_polygon: {
[fieldName]: queryParams,
ignore_unmapped: true,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,5 @@ export const deletePolicy = async (
esClient: ElasticsearchClient,
policy: string
): Promise<unknown> => {
return (
// @ts-expect-error policy_id is required by mistake. fixed in the v8.0
(await esClient.ilm.deleteLifecycle({ policy })).body
);
return (await esClient.ilm.deleteLifecycle({ policy })).body;
};
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ describe('ElasticIndex', () => {
client.tasks.get.mockResolvedValue(
elasticsearchClientMock.createSuccessTransportRequestPromise({
completed: true,
} as estypes.TaskGetResponse)
} as estypes.TasksGetResponse)
);

const info = {
Expand Down Expand Up @@ -248,7 +248,7 @@ describe('ElasticIndex', () => {
reason: 'all shards failed',
failed_shards: [],
},
} as estypes.TaskGetResponse)
} as estypes.TasksGetResponse)
);

const info = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -450,7 +450,7 @@ function withIndex(
client.tasks.get.mockReturnValue(
elasticsearchClientMock.createSuccessTransportRequestPromise({
completed: true,
} as estypes.TaskGetResponse)
} as estypes.TasksGetResponse)
);
client.search.mockReturnValue(
elasticsearchClientMock.createSuccessTransportRequestPromise(searchResult(0) as any)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -242,7 +242,7 @@ const mockV2MigrationOptions = () => {
error: undefined,
failures: [],
task: { description: 'task description' } as any,
} as estypes.TaskGetResponse)
} as estypes.TasksGetResponse)
);

options.client.search = jest
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ export const createIndex = ({
* - acknowledged=true, shards_acknowledged=true, index creation complete
*/
return Either.right({
acknowledged: res.body.acknowledged,
acknowledged: Boolean(res.body.acknowledged),
shardsAcknowledged: res.body.shards_acknowledged,
});
})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ export function getSortingParams(
{
[sortField]: {
order: sortOrder,
unmapped_type: rootField.type,
unmapped_type: rootField.type as estypes.MappingFieldType,
},
},
],
Expand All @@ -73,7 +73,7 @@ export function getSortingParams(
{
[key]: {
order: sortOrder,
unmapped_type: field.type,
unmapped_type: field.type as estypes.MappingFieldType,
},
},
],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -259,7 +259,6 @@ export async function updateObjectsSpaces({
// @ts-expect-error BulkOperation.retry_on_conflict, BulkOperation.routing. BulkOperation.version, and BulkOperation.version_type are optional
bulkOperationParams.push({ update: documentMetadata }, { doc: documentToSave });
} else {
// @ts-expect-error BulkOperation.retry_on_conflict, BulkOperation.routing. BulkOperation.version, and BulkOperation.version_type are optional
bulkOperationParams.push({ delete: documentMetadata });
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,6 @@ export function readFieldCapsResponse(
}),
{}
),
// @ts-expect-error
metadata_field: capsByType[types[0]].metadata_field,
};
// This is intentionally using a "hash" and a "push" to be highly optimized with very large indexes
Expand All @@ -133,7 +132,6 @@ export function readFieldCapsResponse(
searchable: isSearchable,
aggregatable: isAggregatable,
readFromDocValues: shouldReadFieldFromDocValues(isAggregatable, esType),
// @ts-expect-error
metadata_field: capsByType[types[0]].metadata_field,
};
// This is intentionally using a "hash" and a "push" to be highly optimized with very large indexes
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

import { ApiResponse, estypes } from '@elastic/elasticsearch';

type ResponseFailures = Array<Pick<estypes.BulkDeleteResponseItem, '_id' | 'status' | 'result'>>;
type ResponseFailures = Array<Pick<estypes.BulkResponseItem, '_id' | 'status' | 'result'>>;

export function extractBulkResponseDeleteFailures(
response: ApiResponse<estypes.BulkResponse, unknown>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -271,14 +271,15 @@ const getWaterfallDuration = (waterfallItems: IWaterfallItem[]) =>

const getWaterfallItems = (items: TraceAPIResponse['traceDocs']) =>
items.map((item) => {
// @ts-expect-error processor doesn't exist on Profile
const docType = item.processor.event;
switch (docType) {
case 'span':
return getSpanItem(item as Span);
case 'transaction':
return getTransactionItem(item as Transaction);
}
});
}) as IWaterfallSpanOrTransaction[];

function reparentSpans(waterfallItems: IWaterfallSpanOrTransaction[]) {
// find children that needs to be re-parented and map them to their correct parent id
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ describe('Error count alert', () => {
const params = { threshold: 2, windowSize: 5, windowUnit: 'm' };

services.scopedClusterClient.asCurrentUser.search.mockReturnValue(
// @ts-expect-error not full interface
elasticsearchClientMock.createSuccessTransportRequestPromise({
hits: {
hits: [],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ describe('Transaction error rate alert', () => {
});

services.scopedClusterClient.asCurrentUser.search.mockReturnValue(
// @ts-expect-error not full interface
elasticsearchClientMock.createSuccessTransportRequestPromise({
hits: {
hits: [],
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* 2.0; you may not use this file except in compliance with the Elastic License
* 2.0.
*/

import type { estypes } from '@elastic/elasticsearch';
import { asMutableArray } from '../../../common/utils/as_mutable_array';
import {
ERROR_GROUP_ID,
Expand Down Expand Up @@ -55,9 +55,9 @@ export async function getErrorGroupSample({
},
},
sort: asMutableArray([
{ _score: 'desc' }, // sort by _score first to ensure that errors with transaction.sampled:true ends up on top
{ '@timestamp': { order: 'desc' } }, // sort by timestamp to get the most recent error
] as const),
{ _score: { order: 'desc' as const } }, // sort by _score first to ensure that errors with transaction.sampled:true ends up on top
{ '@timestamp': { order: 'desc' as const } }, // sort by timestamp to get the most recent error
]) as estypes.SearchSortCombinations[],
},
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,9 +66,9 @@ export const fetchBooleanFieldStats = async (
termFilters
);
const { body } = await esClient.search(request);
const aggregations = body.aggregations as {
const aggregations = body.aggregations as unknown as {
sample: {
sampled_value_count: estypes.AggregationsFiltersBucketItemKeys;
sampled_value_count: estypes.AggregationsFiltersBucketItem;
sampled_values: estypes.AggregationsTermsAggregate<TopValueBucket>;
};
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ export const fetchKeywordFieldStats = async (
termFilters
);
const { body } = await esClient.search(request);
const aggregations = body.aggregations as {
const aggregations = body.aggregations as unknown as {
sample: {
sampled_top: estypes.AggregationsTermsAggregate<TopValueBucket>;
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ export const fetchNumericFieldStats = async (
);
const { body } = await esClient.search(request);

const aggregations = body.aggregations as {
const aggregations = body.aggregations as unknown as {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

tsc complains sample doesn't exist on Record<string, AggregationsAggregate>. We need to refactor the way elasticsearch-js declares `aggregations type. A first proposal is here elastic/elasticsearch-js#1596

Copy link
Member

Choose a reason for hiding this comment

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

Very likely this new aggregations work will land only in v8.

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 can create some merge conflicts during a bug fix backporting, but let's see

sample: {
sampled_top: estypes.AggregationsTermsAggregate<TopValueBucket>;
sampled_percentiles: estypes.AggregationsHdrPercentilesAggregate;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@ const mappings: Mappings = {
dynamic_templates: [
{
// force string to keyword (instead of default of text + keyword)
// @ts-expect-error @elastic/elasticsearch expects here mapping: MappingPropertyBase
strings: {
match_mapping_type: 'string',
mapping: {
Expand Down
6 changes: 3 additions & 3 deletions x-pack/plugins/fleet/server/services/agents/crud.ts
Original file line number Diff line number Diff line change
Expand Up @@ -315,11 +315,11 @@ export async function bulkUpdateAgents(
});

return {
items: res.body.items.map((item: estypes.BulkResponseItemContainer) => ({
// @ts-expect-error ErrorCause is not assignable to Error
items: res.body.items.map((item) => ({
Copy link
Contributor Author

@mshustov mshustov Nov 4, 2021

Choose a reason for hiding this comment

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

I'm not sure these typings are correct. @joshdover

Copy link
Contributor

Choose a reason for hiding this comment

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

@nchaulet I believe you're more familiar with this code. Should we be wrapping the item.update!.error with new Error()?

Copy link
Member

Choose a reason for hiding this comment

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

Looking at the code looks like we never consume these errors, I am going to investigate a little more what error handling we are missing, but it should not block that PR.

id: item.update!._id as string,
success: !item.update!.error,
// @ts-expect-error ErrorCause is not assignable to Error
error: item.update!.error as Error,
error: item.update!.error,
})),
};
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,6 @@ function putComponentTemplate(
const { name, body, create = false } = params;
return {
clusterPromise: esClient.cluster.putComponentTemplate(
// @ts-expect-error body is missing required key `settings`. TemplateMapEntry has settings *or* mappings
{ name, body, create },
{ ignore: [404] }
),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -212,12 +212,12 @@ export interface IndexLifecyclePolicy {
index: string;
managed: boolean;
action?: string;
action_time_millis?: number;
age?: string;
action_time_millis?: string | number;
age?: string | number;
failed_step?: string;
failed_step_retry_count?: number;
is_auto_retryable_error?: boolean;
lifecycle_date_millis?: number;
lifecycle_date_millis?: string | number;
phase?: string;
phase_execution?: {
policy: string;
Expand Down
2 changes: 1 addition & 1 deletion x-pack/plugins/index_lifecycle_management/server/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,10 @@ const indexLifecycleDataEnricher = async (
index: '*',
});

// @ts-expect-error Property 'phase_definition' is missing in type 'IlmExplainLifecycleLifecycleExplainPhaseExecution'
return indicesList.map((index: IndexWithoutIlm) => {
return {
...index,
// @ts-expect-error @elastic/elasticsearch https://github.com/elastic/elasticsearch-specification/issues/531
ilm: { ...(ilmIndicesData[index.name] || {}) },
};
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ async function deletePolicies(client: ElasticsearchClient, policyName: string):
ignore: [404],
};

// @ts-expect-error @elastic/elasticsearch DeleteSnapshotLifecycleRequest.policy_id is required
return client.ilm.deleteLifecycle({ policy: policyName }, options);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,6 @@ async function fetchIndicesCall(
aliases: aliases.length ? aliases : 'none',
// @ts-expect-error @elastic/elasticsearch https://github.com/elastic/elasticsearch-specification/issues/532
hidden: index.settings.index.hidden === 'true',
// @ts-expect-error @elastic/elasticsearch https://github.com/elastic/elasticsearch-specification/issues/532
data_stream: index.data_stream!,
});
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,6 @@ export const saveTemplate = async ({

return await client.asCurrentUser.indices.putTemplate({
name: template.name,
// @ts-expect-error @elastic/elasticsearch https://github.com/elastic/elasticsearch-specification/issues/533
order,
include_type_name,
body: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* 2.0; you may not use this file except in compliance with the Elastic License
* 2.0.
*/

import type { estypes } from '@elastic/elasticsearch';
import { schema, TypeOf } from '@kbn/config-schema';

import { RouteDependencies } from '../../../types';
Expand All @@ -31,7 +31,7 @@ export function registerSimulateRoute({ router, lib: { handleEsError } }: RouteD
// Issue: https://github.com/elastic/elasticsearch/issues/59152
index_patterns: ['a_fake_index_pattern_that_wont_match_any_indices'],
},
});
} as estypes.IndicesSimulateTemplateRequest);

return response.ok({ body: templatePreview });
} catch (error) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ describe('ExpressionChart', () => {
metricAlias: 'metricbeat-*',
inventoryDefaultView: 'host',
metricsExplorerDefaultView: 'host',

// @ts-ignore message is missing
fields: {
timestamp: '@timestamp',
container: 'container.id',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import { InfraWaffleMapOptions, InfraFormatterType } from '../../../../lib/lib';
import { SnapshotMetricType } from '../../../../../common/inventory_models/types';

const options: InfraWaffleMapOptions = {
// @ts-ignore message is missing
fields: {
container: 'container.id',
pod: 'kubernetes.pod.uid',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ import { fold, map } from 'fp-ts/lib/Either';
import { constant, identity } from 'fp-ts/lib/function';
import { pipe } from 'fp-ts/lib/pipeable';
import * as runtimeTypes from 'io-ts';
import { compact } from 'lodash';
import { JsonArray } from '@kbn/utility-types';
import { compact } from 'lodash';
import type { InfraPluginRequestHandlerContext } from '../../../types';
import {
LogEntriesAdapter,
Expand Down Expand Up @@ -46,7 +46,7 @@ export class InfraKibanaLogEntriesAdapter implements LogEntriesAdapter {
const highlightClause = highlightQuery
? {
highlight: {
boundary_scanner: 'word',
boundary_scanner: 'word' as const,
fields: fields.reduce(
(highlightFieldConfigs, fieldName) => ({
...highlightFieldConfigs,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@
* 2.0.
*/

import { mapValues, first, last, isNaN, isNumber, isObject, has } from 'lodash';
import moment from 'moment';
import { ElasticsearchClient } from 'kibana/server';
import { mapValues, first, last, isNaN, isNumber, isObject, has } from 'lodash';
import {
isTooManyBucketsPreviewException,
TOO_MANY_BUCKETS_PREVIEW_EXCEPTION,
Expand Down Expand Up @@ -222,6 +222,7 @@ const getMetric: (
return groupedResults;
}
const { body: result } = await esClient.search({
// @ts-expect-error buckets_path is not compatible with @elastic/elasticsearch
body: searchBody,
index,
});
Expand Down
Loading