[main] update ES client version (#126129)

* update renovate bot settings

* update es client to 8.1-canary3

* specify type explicitly when pass a serialized object

* attempt 1 in fleet.specify type explicitly when pass a serialized object

* fix the first batch of ts errors

* fix more violations

* fix unit test

* fix more violations 2

* fix more violations 3

* fix more violations 4

* review comments

Co-authored-by: pgayvallet <pierre.gayvallet@elastic.co>
Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com>
This commit is contained in:
Mikhail Shustov 2022-02-25 00:45:18 +01:00 committed by GitHub
parent ef62706a59
commit 0393f3f261
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
33 changed files with 94 additions and 75 deletions

View file

@ -107,7 +107,7 @@
"@elastic/apm-synthtrace": "link:bazel-bin/packages/elastic-apm-synthtrace",
"@elastic/charts": "43.1.1",
"@elastic/datemath": "link:bazel-bin/packages/elastic-datemath",
"@elastic/elasticsearch": "npm:@elastic/elasticsearch-canary@8.1.0-canary.2",
"@elastic/elasticsearch": "npm:@elastic/elasticsearch-canary@8.1.0-canary.3",
"@elastic/ems-client": "8.0.0",
"@elastic/eui": "48.1.1",
"@elastic/filesaver": "1.1.2",

View file

@ -35,14 +35,14 @@
"matchPackageNames": ["@elastic/elasticsearch"],
"reviewers": ["team:kibana-operations", "team:kibana-core"],
"matchBaseBranches": ["main"],
"labels": ["release_note:skip", "backport:skip", "Team:Operations", "Team:Core", "v8.1.0"],
"labels": ["release_note:skip", "backport:skip", "Team:Operations", "Team:Core"],
"enabled": true
},
{
"groupName": "@elastic/elasticsearch",
"matchPackageNames": ["@elastic/elasticsearch"],
"reviewers": ["team:kibana-operations", "team:kibana-core"],
"matchBaseBranches": ["7.16"],
"matchBaseBranches": ["8.1"],
"labels": ["release_note:skip", "Team:Operations", "Team:Core", "backport:skip"],
"enabled": true
},
@ -50,7 +50,7 @@
"groupName": "@elastic/elasticsearch",
"matchPackageNames": ["@elastic/elasticsearch"],
"reviewers": ["team:kibana-operations", "team:kibana-core"],
"matchBaseBranches": ["7.15"],
"matchBaseBranches": ["7.17"],
"labels": ["release_note:skip", "Team:Operations", "Team:Core", "backport:skip"],
"enabled": true
},

View file

@ -53,7 +53,6 @@ async function createIndexTemplate({
await client.indices.putIndexTemplate({
name: templateName,
body: template,
// @ts-expect-error doesn't exist in @elastic/elasticsearch
create: true,
});
} catch (err) {

View file

@ -32,11 +32,11 @@ export const essqlSearchStrategyProvider = (): ISearchStrategy<
format: 'json',
body: {
query,
// @ts-expect-error `params` missing from `QuerySqlRequest` type
params,
field_multi_value_leniency: true,
time_zone: timezone,
fetch_size: count,
// @ts-expect-error `client_id` missing from `QuerySqlRequest` type
client_id: 'canvas',
filter: {
bool: {

View file

@ -393,7 +393,9 @@ describe('setIndexToHidden', () => {
expect(clusterClient.indices.putSettings).toHaveBeenCalledWith({
index: 'foo-bar-000001',
body: {
'index.hidden': true,
index: {
hidden: true,
},
},
});
});

View file

@ -178,7 +178,6 @@ export class ClusterClientAdapter<TDoc extends { body: AliasAny; index: string }
await esClient.indices.putIndexTemplate({
name,
body: template,
// @ts-expect-error doesn't exist in @elastic/elasticsearch
create: true,
});
} catch (err) {
@ -248,7 +247,7 @@ export class ClusterClientAdapter<TDoc extends { body: AliasAny; index: string }
await esClient.indices.putSettings({
index: indexName,
body: {
'index.hidden': true,
index: { hidden: true },
},
});
} catch (err) {

View file

@ -74,13 +74,20 @@ async function handleMlModelInstall({
try {
await retryTransientEsErrors(
() =>
esClient.ml.putTrainedModel({
model_id: mlModel.installationName,
defer_definition_decompression: true,
timeout: '45s',
// @ts-expect-error expects an object not a string
body: mlModel.content,
}),
esClient.ml.putTrainedModel(
{
model_id: mlModel.installationName,
defer_definition_decompression: true,
timeout: '45s',
// @ts-expect-error expects an object not a string
body: mlModel.content,
},
{
headers: {
'content-type': 'application/json',
},
}
),
{ logger }
);
} catch (err) {

View file

@ -46,7 +46,6 @@ export const deleteTransforms = async (esClient: ElasticsearchClient, transformI
await esClient.transport.request(
{
method: 'DELETE',
// @ts-expect-error @elastic/elasticsearch Transform is empty interface
path: `/${transform?.dest?.index}`,
},
{

View file

@ -106,6 +106,7 @@ describe('test transform install', () => {
esClient.transform.getTransform.mockResponseOnce({
count: 1,
transforms: [
// @ts-expect-error incomplete data
{
dest: {
index: 'index',
@ -394,6 +395,7 @@ describe('test transform install', () => {
esClient.transform.getTransform.mockResponseOnce({
count: 1,
transforms: [
// @ts-expect-error incomplete data
{
dest: {
index: 'index',

View file

@ -51,9 +51,7 @@ async function fetchIndicesCall(
const indexStats = indicesStats[indexName];
const aliases = Object.keys(indexData.aliases!);
return {
// @ts-expect-error new property https://github.com/elastic/elasticsearch-specification/issues/1253
health: indexStats?.health,
// @ts-expect-error new property https://github.com/elastic/elasticsearch-specification/issues/1253
status: indexStats?.status,
name: indexName,
uuid: indexStats?.uuid,

View file

@ -18,6 +18,7 @@ interface PutLicenseArg {
export async function putLicense({ acknowledge, client, licensing, license }: PutLicenseArg) {
try {
const response = await client.asCurrentUser.license.post({
// @ts-expect-error license is not typed in LM code
body: license,
acknowledge,
});

View file

@ -19,7 +19,8 @@ export function chartLoaderProvider(mlResultsService: MlResultsService) {
): Promise<LineChartPoint[]> {
const intervalMs = Math.max(
Math.floor(
(job.data_counts.latest_record_timestamp - job.data_counts.earliest_record_timestamp) / bars
(job.data_counts.latest_record_timestamp! - job.data_counts.earliest_record_timestamp!) /
bars
),
bucketSpanMs
);
@ -27,8 +28,8 @@ export function chartLoaderProvider(mlResultsService: MlResultsService) {
job.datafeed_config.indices.join(),
job.datafeed_config.query,
job.data_description.time_field!,
job.data_counts.earliest_record_timestamp,
job.data_counts.latest_record_timestamp,
job.data_counts.earliest_record_timestamp!,
job.data_counts.latest_record_timestamp!,
intervalMs,
job.datafeed_config.runtime_mappings,
job.datafeed_config.indices_options
@ -60,15 +61,16 @@ export function chartLoaderProvider(mlResultsService: MlResultsService) {
) {
const intervalMs = Math.max(
Math.floor(
(job.data_counts.latest_record_timestamp - job.data_counts.earliest_record_timestamp) / bars
(job.data_counts.latest_record_timestamp! - job.data_counts.earliest_record_timestamp!) /
bars
),
bucketSpanMs
);
const resp = await mlResultsService.getScoresByBucket(
[job.job_id],
job.data_counts.earliest_record_timestamp,
job.data_counts.latest_record_timestamp,
job.data_counts.earliest_record_timestamp!,
job.data_counts.latest_record_timestamp!,
intervalMs,
1
);

View file

@ -231,7 +231,7 @@ export const RevertModelSnapshotFlyout: FC<Props> = ({
overlayRanges={[
{
start: currentSnapshot.latest_record_time_stamp,
end: job.data_counts.latest_record_timestamp,
end: job.data_counts.latest_record_timestamp!,
color: '#ff0000',
},
]}
@ -334,7 +334,7 @@ export const RevertModelSnapshotFlyout: FC<Props> = ({
calendarEvents={calendarEvents}
setCalendarEvents={setCalendarEvents}
minSelectableTimeStamp={snapshot.latest_record_time_stamp}
maxSelectableTimeStamp={job.data_counts.latest_record_timestamp}
maxSelectableTimeStamp={job.data_counts.latest_record_timestamp!}
eventRateData={eventRateData}
anomalies={anomalies}
chartReady={chartReady}

View file

@ -44,7 +44,10 @@ interface MLEuiDataGridColumn extends EuiDataGridColumn {
function getRuntimeFieldColumns(runtimeMappings: RuntimeMappings) {
return Object.keys(runtimeMappings).map((id) => {
const field = runtimeMappings[id];
let field = runtimeMappings[id];
if (Array.isArray(field)) {
field = field[0];
}
const schema = getDataGridSchemaFromESFieldType(
field.type as estypes.MappingRuntimeField['type']
);

View file

@ -262,6 +262,7 @@ export class JobCreator {
this._initModelPlotConfig();
this._job_config.model_plot_config!.enabled = enable;
}
public get modelPlot() {
return (
this._job_config.model_plot_config !== undefined &&
@ -737,7 +738,7 @@ export class JobCreator {
({
id,
name: id,
type: runtimeField.type,
type: Array.isArray(runtimeField) ? runtimeField[0].type : runtimeField.type,
aggregatable: true,
aggs: [],
runtimeField,

View file

@ -34,6 +34,7 @@ const NODE_FIELDS = ['attributes', 'name', 'roles', 'version'] as const;
export type RequiredNodeFields = Pick<NodesInfoNodeInfo, typeof NODE_FIELDS[number]>;
// @ts-expect-error TrainedModelDeploymentStatsResponse missing properties from MlTrainedModelDeploymentStats
interface TrainedModelStatsResponse extends MlTrainedModelStats {
deployment_stats?: Omit<TrainedModelDeploymentStatsResponse, 'model_id'>;
model_size_stats?: TrainedModelModelSizeStats;

View file

@ -603,8 +603,8 @@ export class DataRecognizer {
} as JobStat;
if (job.data_counts) {
jobStat.earliestTimestampMs = job.data_counts.earliest_record_timestamp;
jobStat.latestTimestampMs = job.data_counts.latest_record_timestamp;
jobStat.earliestTimestampMs = job.data_counts.earliest_record_timestamp!;
jobStat.latestTimestampMs = job.data_counts.latest_record_timestamp!;
jobStat.latestResultsTimestampMs = getLatestDataOrBucketTimestamp(
jobStat.latestTimestampMs,
latestBucketTimestampsByJob[job.job_id] as number
@ -781,6 +781,7 @@ export class DataRecognizer {
}
private async _saveJob(job: ModuleJob) {
// @ts-expect-error type mismatch on MlPutJobRequest.body
return this._mlClient.putJob({ job_id: job.id, body: job.config });
}

View file

@ -590,7 +590,7 @@ export function jobsProvider(
if (body.jobs.length) {
const statsForJob = body.jobs[0];
const time = statsForJob.data_counts.latest_record_timestamp;
const time = statsForJob.data_counts.latest_record_timestamp!;
const progress = (time - start) / (end - start);
const isJobClosed = statsForJob.state === JOB_STATE.CLOSED;
return {
@ -631,6 +631,7 @@ export function jobsProvider(
results[job.job_id] = { job: { success: false }, datafeed: { success: false } };
try {
// @ts-expect-error type mismatch on MlPutJobRequest.body
await mlClient.putJob({ job_id: job.job_id, body: job });
results[job.job_id].job = { success: true };
} catch (error) {

View file

@ -74,7 +74,7 @@ export function memoryOverviewServiceProvider(mlClient: MlClient) {
.filter((v) => v.state === 'opened')
.map((jobStats) => {
return {
node_id: jobStats.node.id,
node_id: jobStats.node!.id,
// @ts-expect-error model_bytes can be string | number, cannot sum it with AD_PROCESS_MEMORY_OVERHEAD
model_size: jobStats.model_size_stats.model_bytes + AD_PROCESS_MEMORY_OVERHEAD,
job_id: jobStats.job_id,

View file

@ -77,7 +77,7 @@ function createNewIndex({
index,
body: {
// auto_expand_replicas: Allows cluster to not have replicas for this index
settings: { 'index.auto_expand_replicas': '0-1' },
settings: { index: { auto_expand_replicas: '0-1' } },
mappings,
},
});

View file

@ -26,10 +26,17 @@ export function registerExecuteRoute({ router, license }: RouteDependencies) {
try {
const client = ctx.core.elasticsearch.client.asCurrentUser;
const response = await client.scriptsPainlessExecute({
// @ts-expect-error `ExecutePainlessScriptRequest.body` does not allow `string`
body,
});
const response = await client.scriptsPainlessExecute(
{
// @ts-expect-error `ExecutePainlessScriptRequest.body` does not allow `string`
body,
},
{
headers: {
'content-type': 'application/json',
},
}
);
return res.ok({
body: response,

View file

@ -29,6 +29,7 @@ export const checkIlmMigrationStatus = async ({
const hasUnmanagedIndices = Object.values(reportingIndicesSettings).some((settings) => {
return (
settings?.settings?.index?.lifecycle?.name !== ILM_POLICY_NAME &&
// @ts-expect-error index.lifecycle not present on type def
settings?.settings?.['index.lifecycle']?.name !== ILM_POLICY_NAME
);
});

View file

@ -126,8 +126,10 @@ export const registerDeprecationsRoutes = (reporting: ReportingCore, logger: Log
await client.indices.putSettings({
index: indexPattern,
body: {
'index.lifecycle': {
name: ILM_POLICY_NAME,
index: {
lifecycle: {
name: ILM_POLICY_NAME,
},
},
},
});

View file

@ -35,6 +35,7 @@ export const registerCreateRoute = ({
// Create job.
await clusterClient.asCurrentUser.rollup.putJob({
id,
// @ts-expect-error type mismatch on RollupPutJobRequest.body
body: rest,
});
// Then request the newly created job.

View file

@ -309,10 +309,9 @@ export class ResourceInstaller {
template: {
settings: {
hidden: true,
// @ts-expect-error type only defines nested structure
'index.lifecycle': {
name: ilmPolicyName,
// TODO: fix the types in the ES package, they don't include rollover_alias???
// @ts-expect-error
rollover_alias: primaryNamespacedAlias,
},
'index.mapping.total_fields.limit': 1700,

View file

@ -127,8 +127,6 @@ export function registerSnapshotsRoutes({
operator: searchOperator,
})
: '_all',
// @ts-expect-error @elastic/elasticsearch new API params
// https://github.com/elastic/elasticsearch-specification/issues/845
slm_policy_filter:
searchField === 'policyName'
? getSnapshotSearchWildcard({
@ -139,6 +137,7 @@ export function registerSnapshotsRoutes({
})
: '*,_none',
order: sortDirection,
// @ts-expect-error sortField: string is not compatible with SnapshotSnapshotSort type
sort: sortField,
size: pageSize,
offset: pageIndex * pageSize,

View file

@ -29,7 +29,11 @@ interface TestResult {
context: TransformHealthAlertContext;
}
type Transform = estypes.Transform & { id: string; description?: string; sync: object };
type Transform = estypes.TransformGetTransformTransformSummary & {
id: string;
description?: string;
sync: object;
};
type TransformWithAlertingRules = Transform & { alerting_rules: TransformHealthAlertRule[] };

View file

@ -508,12 +508,9 @@ async function deleteTransforms(
transform_id: transformId,
});
const transformConfig = body.transforms[0];
// @ts-expect-error @elastic/elasticsearch doesn't provide typings for Transform
destinationIndex = Array.isArray(transformConfig.dest.index)
? // @ts-expect-error @elastic/elasticsearch doesn't provide typings for Transform
transformConfig.dest.index[0]
: // @ts-expect-error @elastic/elasticsearch doesn't provide typings for Transform
transformConfig.dest.index;
? transformConfig.dest.index[0]
: transformConfig.dest.index;
} catch (getTransformConfigError) {
transformDeleted.error = getTransformConfigError.meta.body.error;
results[transformId] = {

View file

@ -36,11 +36,11 @@ describe('transformFlatSettings', () => {
transformFlatSettings({
settings: {
// Settings that should get preserved
// @ts-expect-error @elastic/elasticsearch doesn't declare it
'index.number_of_replicas': '1',
'index.number_of_shards': '5',
// Blacklisted settings
// @ts-expect-error @elastic/elasticsearch doesn't declare it
'index.allocation.existing_shards_allocator': 'gateway_allocator',
'index.blocks.write': 'true',
'index.creation_date': '1547052614626',
@ -87,11 +87,11 @@ describe('transformFlatSettings', () => {
transformFlatSettings({
settings: {
// Settings that should get preserved
// @ts-expect-error @elastic/elasticsearch doesn't declare it
'index.number_of_replicas': '1',
'index.number_of_shards': '5',
// Deprecated settings
// @ts-expect-error @elastic/elasticsearch doesn't declare it
'index.soft_deletes.enabled': 'true',
'index.translog.retention.size': '5b',
},
@ -111,11 +111,11 @@ describe('transformFlatSettings', () => {
transformFlatSettings({
settings: {
// Settings that should get preserved
// @ts-expect-error @elastic/elasticsearch doesn't declare it
'index.number_of_replicas': '1',
'index.number_of_shards': '5',
// Deprecated settings
// @ts-expect-error @elastic/elasticsearch doesn't declare it
'index.soft_deletes.enabled': 'true',
'index.translog.retention.age': '5d',
},
@ -245,6 +245,7 @@ describe('transformFlatSettings', () => {
expect(
getReindexWarnings({
settings: {
// @ts-expect-error @elastic/elasticsearch doesn't declare it
'index.number_of_replicas': '1',
},
mappings: {},

View file

@ -24,7 +24,6 @@ export function registerCloudBackupStatusRoutes({
repository: CLOUD_SNAPSHOT_REPOSITORY,
snapshot: '_all',
ignore_unavailable: true, // Allow request to succeed even if some snapshots are unavailable.
// @ts-expect-error @elastic/elasticsearch "desc" is a new param
order: 'desc',
sort: 'start_time',
size: 1,

View file

@ -16,7 +16,6 @@ export default function ({ getService }: FtrProviderContext) {
const supportedTestSuites = [
{
suiteTitle: 'supported job with aggregation field',
// @ts-expect-error not convertable to Job type
jobConfig: {
job_id: `fq_supported_aggs_${ts}`,
job_type: 'anomaly_detector',
@ -103,7 +102,6 @@ export default function ({ getService }: FtrProviderContext) {
},
{
suiteTitle: 'supported job with scripted field',
// @ts-expect-error not convertable to Job type
jobConfig: {
job_id: `fq_supported_script_${ts}`,
job_type: 'anomaly_detector',
@ -178,7 +176,6 @@ export default function ({ getService }: FtrProviderContext) {
const unsupportedTestSuites = [
{
suiteTitle: 'unsupported job with bucket_script aggregation field',
// @ts-expect-error not convertable to Job type
jobConfig: {
job_id: `fq_unsupported_aggs_${ts}`,
job_type: 'anomaly_detector',
@ -283,7 +280,6 @@ export default function ({ getService }: FtrProviderContext) {
},
{
suiteTitle: 'unsupported job with partition by of a scripted field',
// @ts-expect-error not convertable to Job type
jobConfig: {
job_id: `fq_unsupported_script_${ts}`,
job_type: 'anomaly_detector',

View file

@ -11,7 +11,6 @@ import type { DataFrameAnalyticsConfig } from '../../../../../plugins/ml/public/
const testADJobs: Array<{ job: Job; datafeed: Datafeed }> = [
{
// @ts-expect-error not full interface
job: {
job_id: 'fq_single_1_smv',
groups: ['farequote', 'automated', 'single-metric'],
@ -64,7 +63,6 @@ const testADJobs: Array<{ job: Job; datafeed: Datafeed }> = [
},
},
{
// @ts-expect-error not full interface
job: {
job_id: 'fq_single_2_smv',
groups: ['farequote', 'automated', 'single-metric'],
@ -117,7 +115,6 @@ const testADJobs: Array<{ job: Job; datafeed: Datafeed }> = [
},
},
{
// @ts-expect-error not full interface
job: {
job_id: 'fq_single_3_smv',
groups: ['farequote', 'automated', 'single-metric'],

View file

@ -2371,12 +2371,12 @@
dependencies:
"@elastic/ecs-helpers" "^1.1.0"
"@elastic/elasticsearch@npm:@elastic/elasticsearch-canary@8.1.0-canary.2":
version "8.1.0-canary.2"
resolved "https://registry.yarnpkg.com/@elastic/elasticsearch-canary/-/elasticsearch-canary-8.1.0-canary.2.tgz#7676b3bdad79a37be4b4ada38f97751314a33a52"
integrity sha512-nmr7yZbvlTqA5SHu/IJZFsU6v14+Y2nx0btMKB9Hjd0vardaibCAdovO9Bp1RPxda2g6XayEkKEzwq5s79xR1g==
"@elastic/elasticsearch@npm:@elastic/elasticsearch-canary@8.1.0-canary.3":
version "8.1.0-canary.3"
resolved "https://registry.yarnpkg.com/@elastic/elasticsearch-canary/-/elasticsearch-canary-8.1.0-canary.3.tgz#a84669ad45ea465e533d860bf99aa55aed781cb3"
integrity sha512-rpsMiJX5sAAlPjfWzZhijQgpu7ZlPwjcJQHCT3wNz03DTDnokLCqkhc8gsU+uqesbQ/GqYUlSL9erCk4GqjOLg==
dependencies:
"@elastic/transport" "^8.1.0-beta.1"
"@elastic/transport" "^8.0.2"
tslib "^2.3.0"
"@elastic/ems-client@8.0.0":
@ -2559,17 +2559,17 @@
ts-node "^10.2.1"
typescript "^4.3.5"
"@elastic/transport@^8.1.0-beta.1":
version "8.1.0-beta.1"
resolved "https://registry.yarnpkg.com/@elastic/transport/-/transport-8.1.0-beta.1.tgz#37fde777cf83226f1ea46bf0a22e51a3e43efb85"
integrity sha512-aqncMX86d3r6tNGlve6HEy+NF8XZXetMxDXpplrOAcShL20mHXkMFTJyUyML01tgfkbbgwXnN714YEjin1u1Xg==
"@elastic/transport@^8.0.2":
version "8.0.2"
resolved "https://registry.yarnpkg.com/@elastic/transport/-/transport-8.0.2.tgz#715f06c7739516867508108df30c33973ca8e81c"
integrity sha512-OlDz3WO3pKE9vSxW4wV/mn7rYCtBmSsDwxr64h/S1Uc/zrIBXb0iUsRMSkiybXugXhjwyjqG2n1Wc7jjFxrskQ==
dependencies:
debug "^4.3.2"
hpagent "^0.1.2"
ms "^2.1.3"
secure-json-parse "^2.4.0"
tslib "^2.3.0"
undici "^4.7.0"
undici "^4.14.1"
"@emotion/babel-plugin-jsx-pragmatic@^0.1.5":
version "0.1.5"
@ -29147,10 +29147,10 @@ undertaker@^1.2.1:
object.reduce "^1.0.0"
undertaker-registry "^1.0.0"
undici@^4.7.0:
version "4.7.0"
resolved "https://registry.yarnpkg.com/undici/-/undici-4.7.0.tgz#3bda286d67bf45d0ab1b94ca6c84e546dcb3b0d4"
integrity sha512-O1q+/EIs4g0HnVMH8colei3qODGiYBLpavWYv3kI+JazBBsBIndnZfUqZ2MEfPJ12H9d56yVdwZG1/nV/xcoSQ==
undici@^4.14.1:
version "4.14.1"
resolved "https://registry.yarnpkg.com/undici/-/undici-4.14.1.tgz#7633b143a8a10d6d63335e00511d071e8d52a1d9"
integrity sha512-WJ+g+XqiZcATcBaUeluCajqy4pEDcQfK1vy+Fo+bC4/mqXI9IIQD/XWHLS70fkGUT6P52Drm7IFslO651OdLPQ==
unfetch@^4.2.0:
version "4.2.0"