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

[main] update ES client version #126129

Merged
merged 14 commits into from
Feb 24, 2022
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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/[email protected].2",
"@elastic/elasticsearch": "npm:@elastic/[email protected].3",
"@elastic/ems-client": "8.0.0",
"@elastic/eui": "48.1.1",
"@elastic/filesaver": "1.1.2",
Expand Down
6 changes: 3 additions & 3 deletions renovate.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,22 +35,22 @@
"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
},
{
"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
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
2 changes: 1 addition & 1 deletion x-pack/plugins/canvas/server/lib/essql_strategy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -393,7 +393,9 @@ describe('setIndexToHidden', () => {
expect(clusterClient.indices.putSettings).toHaveBeenCalledWith({
index: 'foo-bar-000001',
body: {
'index.hidden': true,
index: {
hidden: true,
},
},
});
});
Expand Down
3 changes: 1 addition & 2 deletions x-pack/plugins/event_log/server/es/cluster_client_adapter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -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) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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}`,
},
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,7 @@ describe('test transform install', () => {
esClient.transform.getTransform.mockResponseOnce({
count: 1,
transforms: [
// @ts-expect-error incomplete data
{
dest: {
index: 'index',
Expand Down Expand Up @@ -394,6 +395,7 @@ describe('test transform install', () => {
esClient.transform.getTransform.mockResponseOnce({
count: 1,
transforms: [
// @ts-expect-error incomplete data
{
dest: {
index: 'index',
Expand Down
2 changes: 0 additions & 2 deletions x-pack/plugins/index_management/server/lib/fetch_indices.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
1 change: 1 addition & 0 deletions x-pack/plugins/license_management/server/lib/license.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,16 +19,17 @@ 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
);
const resp = await mlResultsService.getEventRateData(
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
Expand Down Expand Up @@ -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
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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',
},
]}
Expand Down Expand Up @@ -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}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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']
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 &&
Expand Down Expand Up @@ -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,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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 });
}

Expand Down
3 changes: 2 additions & 1 deletion x-pack/plugins/ml/server/models/job_service/jobs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
},
});
Expand Down
15 changes: 11 additions & 4 deletions x-pack/plugins/painless_lab/server/routes/api/execute.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
);
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
},
},
},
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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({
Expand All @@ -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,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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[] };

Expand Down
Loading