From 81512ed9884d17e5ed3ae40888e15322414b850b Mon Sep 17 00:00:00 2001
From: Alison Goryachev
Date: Wed, 24 Feb 2021 16:15:06 -0500
Subject: [PATCH 1/2] [Upgrade Assistant] Align code between branches (#91862)
# Conflicts:
# x-pack/plugins/translations/translations/ja-JP.json
# x-pack/plugins/translations/translations/zh-CN.json
# x-pack/plugins/upgrade_assistant/common/types.ts
# x-pack/plugins/upgrade_assistant/public/application/components/tabs.test.tsx
# x-pack/plugins/upgrade_assistant/public/application/components/tabs/checkup/checkup_tab.test.tsx
# x-pack/plugins/upgrade_assistant/public/application/components/tabs/checkup/deprecations/index_table.tsx
# x-pack/plugins/upgrade_assistant/public/application/components/tabs/checkup/deprecations/reindex/flyout/__snapshots__/warning_step.test.tsx.snap
# x-pack/plugins/upgrade_assistant/public/application/components/tabs/checkup/deprecations/reindex/flyout/warning_step.test.tsx
# x-pack/plugins/upgrade_assistant/public/application/components/tabs/checkup/deprecations/reindex/flyout/warnings_step.tsx
# x-pack/plugins/upgrade_assistant/server/lib/reindexing/index_settings.test.ts
# x-pack/plugins/upgrade_assistant/server/lib/reindexing/index_settings.ts
# x-pack/plugins/upgrade_assistant/server/lib/reindexing/reindex_service.ts
# x-pack/plugins/upgrade_assistant/server/lib/reindexing/types.ts
---
.../translations/translations/ja-JP.json | 4 -
.../translations/translations/zh-CN.json | 4 -
.../upgrade_assistant/common/constants.ts | 15 +
.../plugins/upgrade_assistant/common/types.ts | 3 +-
x-pack/plugins/upgrade_assistant/kibana.json | 2 +-
.../application/components/tabs.test.tsx | 9 +-
.../tabs/checkup/checkup_tab.test.tsx | 10 +-
.../tabs/checkup/deprecations/cell.tsx | 9 -
.../deprecations/default_fields/button.tsx | 133 --
.../tabs/checkup/deprecations/index_table.tsx | 45 +-
.../__snapshots__/warning_step.test.tsx.snap | 62 -
.../reindex/flyout/checklist_step.test.tsx | 2 +-
.../reindex/flyout/checklist_step.tsx | 28 -
.../reindex/flyout/warning_step.test.tsx | 44 +-
.../reindex/flyout/warnings_step.tsx | 32 +-
.../server/lib/__fixtures__/version.ts | 11 +-
.../server/lib/apm/extract_index_patterns.ts | 22 -
.../server/lib/apm/index.test.ts | 136 --
.../upgrade_assistant/server/lib/apm/index.ts | 493 -----
.../server/lib/apm/mapping.json | 1598 -----------------
.../server/lib/es_migration_apis.ts | 16 +-
.../server/lib/es_version_precheck.test.ts | 5 +-
.../lib/reindexing/index_settings.test.ts | 45 +-
.../server/lib/reindexing/index_settings.ts | 39 +-
.../lib/reindexing/reindex_actions.test.ts | 5 +-
.../server/lib/reindexing/reindex_actions.ts | 34 +-
.../lib/reindexing/reindex_service.test.ts | 86 +-
.../server/lib/reindexing/reindex_service.ts | 27 +-
.../server/lib/reindexing/types.ts | 4 +
.../server/lib/reindexing/worker.ts | 4 -
.../upgrade_assistant/server/plugin.ts | 15 +-
.../server/routes/cluster_checkup.test.ts | 21 -
.../server/routes/cluster_checkup.ts | 8 +-
.../reindex_indices/reindex_indices.test.ts | 6 +-
.../routes/reindex_indices/reindex_indices.ts | 3 -
.../plugins/upgrade_assistant/server/types.ts | 2 -
.../plugins/upgrade_assistant/tsconfig.json | 1 -
37 files changed, 169 insertions(+), 2814 deletions(-)
create mode 100644 x-pack/plugins/upgrade_assistant/common/constants.ts
delete mode 100644 x-pack/plugins/upgrade_assistant/public/application/components/tabs/checkup/deprecations/default_fields/button.tsx
delete mode 100644 x-pack/plugins/upgrade_assistant/server/lib/apm/extract_index_patterns.ts
delete mode 100644 x-pack/plugins/upgrade_assistant/server/lib/apm/index.test.ts
delete mode 100644 x-pack/plugins/upgrade_assistant/server/lib/apm/index.ts
delete mode 100644 x-pack/plugins/upgrade_assistant/server/lib/apm/mapping.json
diff --git a/x-pack/plugins/translations/translations/ja-JP.json b/x-pack/plugins/translations/translations/ja-JP.json
index 7f2a8e986b5d4..50ba18f93b687 100644
--- a/x-pack/plugins/translations/translations/ja-JP.json
+++ b/x-pack/plugins/translations/translations/ja-JP.json
@@ -21547,10 +21547,6 @@
"xpack.upgradeAssistant.checkupTab.reindexing.flyout.indexClosedCallout.calloutDetails.reindexingTakesLongerEmphasis": "再インデックスには通常よりも時間がかかることがあります",
"xpack.upgradeAssistant.checkupTab.reindexing.flyout.indexClosedCallout.calloutTitle": "インデックスが閉じました",
"xpack.upgradeAssistant.checkupTab.reindexing.flyout.openAndCloseDocumentation": "ドキュメンテーション",
- "xpack.upgradeAssistant.checkupTab.reindexing.flyout.warningsStep.apmReindexWarningDetail": "バージョン 7.0.0 以降、APM データは Elastic Common Schema で表示されます。過去の APM データは再インデックスされるまで表示されません。",
- "xpack.upgradeAssistant.checkupTab.reindexing.flyout.warningsStep.apmReindexWarningTitle": "このインデックスは ECS 形式に変換されます",
- "xpack.upgradeAssistant.checkupTab.reindexing.flyout.warningsStep.customTypeNameWarningDetail": "マッピングタイプは8.xではサポートされていません。このインデックスマッピングはデフォルトのタイプ名、{defaultType}を使用しておらず、再インデックス時に更新されます。アプリケーションコードまたはスクリプトが異なるタイプに依存していないことを確認してください。",
- "xpack.upgradeAssistant.checkupTab.reindexing.flyout.warningsStep.customTypeNameWarningTitle": "マッピングタイプが{defaultType}に変更されます",
"xpack.upgradeAssistant.checkupTab.reindexing.flyout.warningsStep.destructiveCallout.calloutDetail": "インデックスをバックアップして、互換性を破るそれぞれの変更に同意することで再インデックスしてください。",
"xpack.upgradeAssistant.checkupTab.reindexing.flyout.warningsStep.destructiveCallout.calloutTitle": "このインデックスには元に戻すことのできない破壊的な変更が含まれています",
"xpack.upgradeAssistant.checkupTab.reindexing.flyout.warningsStep.documentationLinkLabel": "ドキュメント",
diff --git a/x-pack/plugins/translations/translations/zh-CN.json b/x-pack/plugins/translations/translations/zh-CN.json
index 1eee5f0d2f4dc..179e60b68cbeb 100644
--- a/x-pack/plugins/translations/translations/zh-CN.json
+++ b/x-pack/plugins/translations/translations/zh-CN.json
@@ -21597,10 +21597,6 @@
"xpack.upgradeAssistant.checkupTab.reindexing.flyout.indexClosedCallout.calloutDetails.reindexingTakesLongerEmphasis": "重新索引可能比通常花费更多的时间",
"xpack.upgradeAssistant.checkupTab.reindexing.flyout.indexClosedCallout.calloutTitle": "索引已关闭",
"xpack.upgradeAssistant.checkupTab.reindexing.flyout.openAndCloseDocumentation": "文档",
- "xpack.upgradeAssistant.checkupTab.reindexing.flyout.warningsStep.apmReindexWarningDetail": "从版本 7.0.0 开始,将以 Elastic Common Schema 格式表示 APM 数据。只有重新索引历史 APM 数据后,其才可见。",
- "xpack.upgradeAssistant.checkupTab.reindexing.flyout.warningsStep.apmReindexWarningTitle": "此索引将转换成 ECS 格式",
- "xpack.upgradeAssistant.checkupTab.reindexing.flyout.warningsStep.customTypeNameWarningDetail": "映射类型在 8.x 中不再受支持。此索引映射不使用默认类型名称 {defaultType},并将在重新索引时更新。确保没有应用程序代码或脚本依赖其他类型。",
- "xpack.upgradeAssistant.checkupTab.reindexing.flyout.warningsStep.customTypeNameWarningTitle": "映射类型将更改为 {defaultType}",
"xpack.upgradeAssistant.checkupTab.reindexing.flyout.warningsStep.destructiveCallout.calloutDetail": "备份您的索引,然后通过接受每个重大更改来继续重新索引。",
"xpack.upgradeAssistant.checkupTab.reindexing.flyout.warningsStep.destructiveCallout.calloutTitle": "此索引需要无法撤消的破坏性更改",
"xpack.upgradeAssistant.checkupTab.reindexing.flyout.warningsStep.documentationLinkLabel": "文档",
diff --git a/x-pack/plugins/upgrade_assistant/common/constants.ts b/x-pack/plugins/upgrade_assistant/common/constants.ts
new file mode 100644
index 0000000000000..d9a056cebcc21
--- /dev/null
+++ b/x-pack/plugins/upgrade_assistant/common/constants.ts
@@ -0,0 +1,15 @@
+/*
+ * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
+ * or more contributor license agreements. Licensed under the Elastic License
+ * 2.0; you may not use this file except in compliance with the Elastic License
+ * 2.0.
+ */
+import SemVer from 'semver/classes/semver';
+
+/*
+ * These constants are used only in tests to add conditional logic based on Kibana version
+ * On master, the version should represent the next major version (e.g., master --> 8.0.0)
+ * The release branch should match the release version (e.g., 7.x --> 7.0.0)
+ */
+export const mockKibanaVersion = '7.0.0';
+export const mockKibanaSemverVersion = new SemVer(mockKibanaVersion);
diff --git a/x-pack/plugins/upgrade_assistant/common/types.ts b/x-pack/plugins/upgrade_assistant/common/types.ts
index 3be01fdb8f7dc..adf0661feb66b 100644
--- a/x-pack/plugins/upgrade_assistant/common/types.ts
+++ b/x-pack/plugins/upgrade_assistant/common/types.ts
@@ -94,8 +94,9 @@ export type ReindexSavedObject = SavedObject;
export enum ReindexWarning {
// 7.0 -> 8.0 warnings
- apmReindex,
customTypeName,
+
+ // 8.0 -> 9.0 warnings
}
export enum IndexGroup {
diff --git a/x-pack/plugins/upgrade_assistant/kibana.json b/x-pack/plugins/upgrade_assistant/kibana.json
index 0a3da4c055b1c..c4c6f23611f2b 100644
--- a/x-pack/plugins/upgrade_assistant/kibana.json
+++ b/x-pack/plugins/upgrade_assistant/kibana.json
@@ -4,6 +4,6 @@
"server": true,
"ui": true,
"configPath": ["xpack", "upgrade_assistant"],
- "requiredPlugins": ["management", "licensing", "apmOss", "features"],
+ "requiredPlugins": ["management", "licensing", "features"],
"optionalPlugins": ["cloud", "usageCollection"]
}
diff --git a/x-pack/plugins/upgrade_assistant/public/application/components/tabs.test.tsx b/x-pack/plugins/upgrade_assistant/public/application/components/tabs.test.tsx
index 8810569027cc8..b732f6806a388 100644
--- a/x-pack/plugins/upgrade_assistant/public/application/components/tabs.test.tsx
+++ b/x-pack/plugins/upgrade_assistant/public/application/components/tabs.test.tsx
@@ -6,9 +6,9 @@
*/
import React from 'react';
-import SemVer from 'semver/classes/semver';
import { mountWithIntl } from '@kbn/test/jest';
import { httpServiceMock } from 'src/core/public/mocks';
+import { mockKibanaSemverVersion } from '../../../common/constants';
import { UpgradeAssistantTabs } from './tabs';
import { LoadingState } from './types';
@@ -18,7 +18,6 @@ import { OverviewTab } from './tabs/overview';
const promisesToResolve = () => new Promise((resolve) => setTimeout(resolve, 0));
const mockHttp = httpServiceMock.createSetupContract();
-const mockKibanaVersion = new SemVer('7.0.0');
jest.mock('../app_context', () => {
return {
@@ -29,9 +28,9 @@ jest.mock('../app_context', () => {
ELASTIC_WEBSITE_URL: 'https://www.elastic.co/',
},
kibanaVersionInfo: {
- currentMajor: mockKibanaVersion.major,
- prevMajor: mockKibanaVersion.major - 1,
- nextMajor: mockKibanaVersion.major + 1,
+ currentMajor: mockKibanaSemverVersion.major,
+ prevMajor: mockKibanaSemverVersion.major - 1,
+ nextMajor: mockKibanaSemverVersion.major + 1,
},
};
},
diff --git a/x-pack/plugins/upgrade_assistant/public/application/components/tabs/checkup/checkup_tab.test.tsx b/x-pack/plugins/upgrade_assistant/public/application/components/tabs/checkup/checkup_tab.test.tsx
index feffd4f7853cd..bf890c856239e 100644
--- a/x-pack/plugins/upgrade_assistant/public/application/components/tabs/checkup/checkup_tab.test.tsx
+++ b/x-pack/plugins/upgrade_assistant/public/application/components/tabs/checkup/checkup_tab.test.tsx
@@ -7,7 +7,7 @@
import { shallow } from 'enzyme';
import React from 'react';
-import SemVer from 'semver/classes/semver';
+import { mockKibanaSemverVersion } from '../../../../../common/constants';
import { LoadingState } from '../../types';
import AssistanceData from '../__fixtures__/checkup_api_response.json';
@@ -22,8 +22,6 @@ const defaultProps = {
setSelectedTabIndex: jest.fn(),
};
-const mockKibanaVersion = new SemVer('7.0.0');
-
jest.mock('../../../app_context', () => {
return {
useAppContext: () => {
@@ -33,9 +31,9 @@ jest.mock('../../../app_context', () => {
ELASTIC_WEBSITE_URL: 'https://www.elastic.co/',
},
kibanaVersionInfo: {
- currentMajor: mockKibanaVersion.major,
- prevMajor: mockKibanaVersion.major - 1,
- nextMajor: mockKibanaVersion.major + 1,
+ currentMajor: mockKibanaSemverVersion.major,
+ prevMajor: mockKibanaSemverVersion.major - 1,
+ nextMajor: mockKibanaSemverVersion.major + 1,
},
};
},
diff --git a/x-pack/plugins/upgrade_assistant/public/application/components/tabs/checkup/deprecations/cell.tsx b/x-pack/plugins/upgrade_assistant/public/application/components/tabs/checkup/deprecations/cell.tsx
index dd69263b1c856..d7487c2744b2b 100644
--- a/x-pack/plugins/upgrade_assistant/public/application/components/tabs/checkup/deprecations/cell.tsx
+++ b/x-pack/plugins/upgrade_assistant/public/application/components/tabs/checkup/deprecations/cell.tsx
@@ -17,7 +17,6 @@ import {
EuiTitle,
} from '@elastic/eui';
import { FormattedMessage } from '@kbn/i18n/react';
-import { FixDefaultFieldsButton } from './default_fields/button';
import { ReindexButton } from './reindex';
import { AppContext } from '../../../../app_context';
import { EnrichedDeprecationInfo } from '../../../../../../common/types';
@@ -99,14 +98,6 @@ export const DeprecationCell: FunctionComponent = ({
)}
-
- {needsDefaultFields && (
-
-
- {({ http }) => }
-
-
- )}
diff --git a/x-pack/plugins/upgrade_assistant/public/application/components/tabs/checkup/deprecations/default_fields/button.tsx b/x-pack/plugins/upgrade_assistant/public/application/components/tabs/checkup/deprecations/default_fields/button.tsx
deleted file mode 100644
index 327051c6e6092..0000000000000
--- a/x-pack/plugins/upgrade_assistant/public/application/components/tabs/checkup/deprecations/default_fields/button.tsx
+++ /dev/null
@@ -1,133 +0,0 @@
-/*
- * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
- * or more contributor license agreements. Licensed under the Elastic License
- * 2.0; you may not use this file except in compliance with the Elastic License
- * 2.0.
- */
-
-import React, { ReactNode } from 'react';
-import { HttpSetup } from 'src/core/public';
-
-import { EuiButton } from '@elastic/eui';
-import { FormattedMessage } from '@kbn/i18n/react';
-import { LoadingState } from '../../../../types';
-
-/**
- * Field types used by Metricbeat to generate the default_field setting.
- * Matches Beats code here:
- * https://github.com/elastic/beats/blob/eee127cb59b56f2ed7c7e317398c3f79c4158216/libbeat/template/processor.go#L104
- */
-const BEAT_DEFAULT_FIELD_TYPES: ReadonlySet = new Set(['keyword', 'text', 'ip']);
-const BEAT_OTHER_DEFAULT_FIELDS: ReadonlySet = new Set(['fields.*']);
-
-interface FixDefaultFieldsButtonProps {
- http: HttpSetup;
- indexName: string;
-}
-
-interface FixDefaultFieldsButtonState {
- fixLoadingState?: LoadingState;
-}
-
-/**
- * Renders a button if given index is a valid Metricbeat index to add a default_field setting.
- */
-export class FixDefaultFieldsButton extends React.Component<
- FixDefaultFieldsButtonProps,
- FixDefaultFieldsButtonState
-> {
- constructor(props: FixDefaultFieldsButtonProps) {
- super(props);
- this.state = {};
- }
-
- public render() {
- const { fixLoadingState } = this.state;
-
- if (!this.isBeatsIndex()) {
- return null;
- }
-
- const buttonProps: any = { size: 's', onClick: this.fixBeatsIndex };
- let buttonContent: ReactNode;
-
- switch (fixLoadingState) {
- case LoadingState.Loading:
- buttonProps.disabled = true;
- buttonProps.isLoading = true;
- buttonContent = (
-
- );
- break;
- case LoadingState.Success:
- buttonProps.iconSide = 'left';
- buttonProps.iconType = 'check';
- buttonProps.disabled = true;
- buttonContent = (
-
- );
- break;
- case LoadingState.Error:
- buttonProps.color = 'danger';
- buttonProps.iconSide = 'left';
- buttonProps.iconType = 'cross';
- buttonContent = (
-
- );
- break;
- default:
- buttonContent = (
-
- );
- }
-
- return {buttonContent};
- }
-
- private isBeatsIndex = () => {
- const { indexName } = this.props;
- return indexName.startsWith('metricbeat-') || indexName.startsWith('filebeat-');
- };
-
- private fixBeatsIndex = async () => {
- if (!this.isBeatsIndex()) {
- return;
- }
-
- this.setState({
- fixLoadingState: LoadingState.Loading,
- });
-
- try {
- await this.props.http.post(
- `/api/upgrade_assistant/add_query_default_field/${this.props.indexName}`,
- {
- body: JSON.stringify({
- fieldTypes: [...BEAT_DEFAULT_FIELD_TYPES],
- otherFields: [...BEAT_OTHER_DEFAULT_FIELDS],
- }),
- }
- );
-
- this.setState({
- fixLoadingState: LoadingState.Success,
- });
- } catch (e) {
- this.setState({
- fixLoadingState: LoadingState.Error,
- });
- }
- };
-}
diff --git a/x-pack/plugins/upgrade_assistant/public/application/components/tabs/checkup/deprecations/index_table.tsx b/x-pack/plugins/upgrade_assistant/public/application/components/tabs/checkup/deprecations/index_table.tsx
index d7925655b556b..79c31ba0b6bb1 100644
--- a/x-pack/plugins/upgrade_assistant/public/application/components/tabs/checkup/deprecations/index_table.tsx
+++ b/x-pack/plugins/upgrade_assistant/public/application/components/tabs/checkup/deprecations/index_table.tsx
@@ -10,7 +10,6 @@ import React from 'react';
import { EuiBasicTable } from '@elastic/eui';
import { i18n } from '@kbn/i18n';
-import { FixDefaultFieldsButton } from './default_fields/button';
import { ReindexButton } from './reindex';
import { AppContext } from '../../../../app_context';
import { EnrichedDeprecationInfo } from '../../../../../../common/types';
@@ -145,11 +144,11 @@ export class IndexDeprecationTable extends React.Component<
private generateActionsColumn() {
// NOTE: this naive implementation assumes all indices in the table are
- // should show the reindex button. This should work for known usecases.
+ // should show the reindex button. This should work for known use cases.
const { indices } = this.props;
- const showReindexButton = indices.find((i) => i.reindex === true);
- const showNeedsDefaultFieldsButton = indices.find((i) => i.needsDefaultFields === true);
- if (!showReindexButton && !showNeedsDefaultFieldsButton) {
+ const hasActionsColumn = Boolean(indices.find((i) => i.reindex === true));
+
+ if (hasActionsColumn === false) {
return null;
}
@@ -157,28 +156,20 @@ export class IndexDeprecationTable extends React.Component<
actions: [
{
render(indexDep: IndexDeprecationDetails) {
- if (showReindexButton) {
- return (
-
- {({ http, docLinks }) => {
- return (
-
- );
- }}
-
- );
- } else {
- return (
-
- {({ http }) => }
-
- );
- }
+ return (
+
+ {({ http, docLinks }) => {
+ return (
+
+ );
+ }}
+
+ );
},
},
],
diff --git a/x-pack/plugins/upgrade_assistant/public/application/components/tabs/checkup/deprecations/reindex/flyout/__snapshots__/warning_step.test.tsx.snap b/x-pack/plugins/upgrade_assistant/public/application/components/tabs/checkup/deprecations/reindex/flyout/__snapshots__/warning_step.test.tsx.snap
index 6343bdde9fc32..dba019550f2a1 100644
--- a/x-pack/plugins/upgrade_assistant/public/application/components/tabs/checkup/deprecations/reindex/flyout/__snapshots__/warning_step.test.tsx.snap
+++ b/x-pack/plugins/upgrade_assistant/public/application/components/tabs/checkup/deprecations/reindex/flyout/__snapshots__/warning_step.test.tsx.snap
@@ -23,68 +23,6 @@ exports[`WarningsFlyoutStep renders 1`] = `
-
- _doc
- ,
- }
- }
- />
- }
- documentationUrl="https://www.elastic.co/guide/en/elasticsearch/reference/current/removal-of-types.html"
- label={
-
- _doc
- ,
- }
- }
- />
- }
- onChange={[Function]}
- warning={1}
- />
-
- }
- documentationUrl="https://www.elastic.co/guide/en/observability/master/whats-new.html"
- label={
-
- }
- onChange={[Function]}
- warning={0}
- />
{
status: undefined,
reindexTaskPercComplete: null,
errorMessage: null,
- reindexWarnings: [ReindexWarning.apmReindex],
+ reindexWarnings: [ReindexWarning.customTypeName],
hasRequiredPrivileges: true,
} as ReindexState,
};
diff --git a/x-pack/plugins/upgrade_assistant/public/application/components/tabs/checkup/deprecations/reindex/flyout/checklist_step.tsx b/x-pack/plugins/upgrade_assistant/public/application/components/tabs/checkup/deprecations/reindex/flyout/checklist_step.tsx
index 6ea97479fbf6d..353937d1e1d32 100644
--- a/x-pack/plugins/upgrade_assistant/public/application/components/tabs/checkup/deprecations/reindex/flyout/checklist_step.tsx
+++ b/x-pack/plugins/upgrade_assistant/public/application/components/tabs/checkup/deprecations/reindex/flyout/checklist_step.tsx
@@ -135,34 +135,6 @@ export const ChecklistFlyoutStep: React.FunctionComponent<{
- {reindexWarnings && reindexWarnings.includes(ReindexWarning.apmReindex) && (
-
-
-
-
-
- ),
- }}
- />
- }
- color="warning"
- iconType="alert"
- />
-
- )}
diff --git a/x-pack/plugins/upgrade_assistant/public/application/components/tabs/checkup/deprecations/reindex/flyout/warning_step.test.tsx b/x-pack/plugins/upgrade_assistant/public/application/components/tabs/checkup/deprecations/reindex/flyout/warning_step.test.tsx
index 0ebf42df53188..d365cd82ba86c 100644
--- a/x-pack/plugins/upgrade_assistant/public/application/components/tabs/checkup/deprecations/reindex/flyout/warning_step.test.tsx
+++ b/x-pack/plugins/upgrade_assistant/public/application/components/tabs/checkup/deprecations/reindex/flyout/warning_step.test.tsx
@@ -8,6 +8,7 @@
import { I18nProvider } from '@kbn/i18n/react';
import { mount, shallow } from 'enzyme';
import React from 'react';
+import { mockKibanaSemverVersion } from '../../../../../../../../common/constants';
import { ReindexWarning } from '../../../../../../../../common/types';
import { idForWarning, WarningsFlyoutStep } from './warnings_step';
@@ -20,6 +21,11 @@ jest.mock('../../../../../../app_context', () => {
DOC_LINK_VERSION: 'current',
ELASTIC_WEBSITE_URL: 'https://www.elastic.co/',
},
+ kibanaVersionInfo: {
+ currentMajor: mockKibanaSemverVersion.major,
+ prevMajor: mockKibanaSemverVersion.major - 1,
+ nextMajor: mockKibanaSemverVersion.major + 1,
+ },
};
},
};
@@ -28,7 +34,7 @@ jest.mock('../../../../../../app_context', () => {
describe('WarningsFlyoutStep', () => {
const defaultProps = {
advanceNextStep: jest.fn(),
- warnings: [ReindexWarning.customTypeName, ReindexWarning.apmReindex],
+ warnings: [ReindexWarning.customTypeName],
closeFlyout: jest.fn(),
renderGlobalCallouts: jest.fn(),
};
@@ -37,23 +43,21 @@ describe('WarningsFlyoutStep', () => {
expect(shallow()).toMatchSnapshot();
});
- it('does not allow proceeding until all are checked', () => {
- const wrapper = mount(
-
-
-
- );
- const button = wrapper.find('EuiButton');
-
- button.simulate('click');
- expect(defaultProps.advanceNextStep).not.toHaveBeenCalled();
-
- wrapper.find(`input#${idForWarning(ReindexWarning.apmReindex)}`).simulate('change');
- button.simulate('click');
- expect(defaultProps.advanceNextStep).not.toHaveBeenCalled();
-
- wrapper.find(`input#${idForWarning(ReindexWarning.customTypeName)}`).simulate('change');
- button.simulate('click');
- expect(defaultProps.advanceNextStep).toHaveBeenCalled();
- });
+ if (mockKibanaSemverVersion.major === 7) {
+ it('does not allow proceeding until all are checked', () => {
+ const wrapper = mount(
+
+
+
+ );
+ const button = wrapper.find('EuiButton');
+
+ button.simulate('click');
+ expect(defaultProps.advanceNextStep).not.toHaveBeenCalled();
+
+ wrapper.find(`input#${idForWarning(ReindexWarning.customTypeName)}`).simulate('change');
+ button.simulate('click');
+ expect(defaultProps.advanceNextStep).toHaveBeenCalled();
+ });
+ }
});
diff --git a/x-pack/plugins/upgrade_assistant/public/application/components/tabs/checkup/deprecations/reindex/flyout/warnings_step.tsx b/x-pack/plugins/upgrade_assistant/public/application/components/tabs/checkup/deprecations/reindex/flyout/warnings_step.tsx
index ebcd97255538c..fe29941f801cc 100644
--- a/x-pack/plugins/upgrade_assistant/public/application/components/tabs/checkup/deprecations/reindex/flyout/warnings_step.tsx
+++ b/x-pack/plugins/upgrade_assistant/public/application/components/tabs/checkup/deprecations/reindex/flyout/warnings_step.tsx
@@ -101,10 +101,9 @@ export const WarningsFlyoutStep: React.FunctionComponent
@@ -130,7 +129,7 @@ export const WarningsFlyoutStep: React.FunctionComponent
- {warnings.includes(ReindexWarning.customTypeName) && (
+ {kibanaVersionInfo.currentMajor === 7 && warnings.includes(ReindexWarning.customTypeName) && (
_doc,
}}
@@ -158,28 +156,6 @@ export const WarningsFlyoutStep: React.FunctionComponent
)}
-
- {warnings.includes(ReindexWarning.apmReindex) && (
-
- }
- description={
-
- }
- documentationUrl={`${observabilityDocBasePath}/master/whats-new.html`}
- />
- )}
diff --git a/x-pack/plugins/upgrade_assistant/server/lib/__fixtures__/version.ts b/x-pack/plugins/upgrade_assistant/server/lib/__fixtures__/version.ts
index 6caad4f5050fc..d93fe7920f1d7 100644
--- a/x-pack/plugins/upgrade_assistant/server/lib/__fixtures__/version.ts
+++ b/x-pack/plugins/upgrade_assistant/server/lib/__fixtures__/version.ts
@@ -5,16 +5,13 @@
* 2.0.
*/
-import { SemVer } from 'semver';
+import { mockKibanaSemverVersion } from '../../../common/constants';
-export const MOCK_VERSION_STRING = '8.0.0';
-
-export const getMockVersionInfo = (versionString = MOCK_VERSION_STRING) => {
- const currentVersion = new SemVer(versionString);
- const currentMajor = currentVersion.major;
+export const getMockVersionInfo = () => {
+ const currentMajor = mockKibanaSemverVersion.major;
return {
- currentVersion,
+ currentVersion: mockKibanaSemverVersion,
currentMajor,
prevMajor: currentMajor - 1,
nextMajor: currentMajor + 1,
diff --git a/x-pack/plugins/upgrade_assistant/server/lib/apm/extract_index_patterns.ts b/x-pack/plugins/upgrade_assistant/server/lib/apm/extract_index_patterns.ts
deleted file mode 100644
index 163373bd7f419..0000000000000
--- a/x-pack/plugins/upgrade_assistant/server/lib/apm/extract_index_patterns.ts
+++ /dev/null
@@ -1,22 +0,0 @@
-/*
- * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
- * or more contributor license agreements. Licensed under the Elastic License
- * 2.0; you may not use this file except in compliance with the Elastic License
- * 2.0.
- */
-
-import { uniq, pick } from 'lodash';
-import { APMOSSConfig } from '../../../../../../src/plugins/apm_oss/server';
-
-export const extractIndexPatterns = (apmConfig: APMOSSConfig): string[] => {
- const indexConfigs = pick(apmConfig, [
- 'sourcemapIndices',
- 'errorIndices',
- 'transactionIndices',
- 'spanIndices',
- 'metricsIndices',
- 'onboardingIndices',
- ]);
-
- return uniq(Object.values(indexConfigs));
-};
diff --git a/x-pack/plugins/upgrade_assistant/server/lib/apm/index.test.ts b/x-pack/plugins/upgrade_assistant/server/lib/apm/index.test.ts
deleted file mode 100644
index 74d36140175ff..0000000000000
--- a/x-pack/plugins/upgrade_assistant/server/lib/apm/index.test.ts
+++ /dev/null
@@ -1,136 +0,0 @@
-/*
- * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
- * or more contributor license agreements. Licensed under the Elastic License
- * 2.0; you may not use this file except in compliance with the Elastic License
- * 2.0.
- */
-
-import { RequestEvent } from '@elastic/elasticsearch/lib/Transport';
-// eslint-disable-next-line @kbn/eslint/no-restricted-paths
-import { ScopedClusterClientMock } from 'src/core/server/elasticsearch/client/mocks';
-import { elasticsearchServiceMock } from 'src/core/server/mocks';
-import { getDeprecatedApmIndices, isLegacyApmIndex } from './index';
-
-describe('getDeprecatedApmIndices', () => {
- let clusterClient: ScopedClusterClientMock;
-
- const asApiResponse = (body: T): RequestEvent =>
- ({
- body,
- } as RequestEvent);
-
- beforeEach(() => {
- clusterClient = elasticsearchServiceMock.createScopedClusterClient();
-
- clusterClient.asCurrentUser.indices.getMapping.mockResolvedValueOnce(
- asApiResponse({
- 'foo-1': {
- mappings: {},
- },
- 'foo-2': {
- mappings: {
- _meta: {
- version: '6.7.0',
- },
- },
- },
- 'foo-3': {
- mappings: {
- _meta: {
- version: '7.0.0',
- },
- },
- },
- 'foo-4': {
- mappings: {
- _meta: {
- version: '7.1.0',
- },
- },
- },
- })
- );
- });
-
- it('calls indices.getMapping', async () => {
- await getDeprecatedApmIndices(clusterClient, ['foo-*', 'bar-*']);
-
- expect(clusterClient.asCurrentUser.indices.getMapping).toHaveBeenCalledWith({
- index: 'foo-*,bar-*',
- filter_path: '*.mappings._meta.version,*.mappings.properties.@timestamp',
- });
- });
-
- it('includes mappings not yet at 7.0.0', async () => {
- const deprecations = await getDeprecatedApmIndices(clusterClient, ['foo-*']);
-
- expect(deprecations).toHaveLength(2);
- expect(deprecations[0].index).toEqual('foo-1');
- expect(deprecations[1].index).toEqual('foo-2');
- });
-
- it('formats the deprecations', async () => {
- // @ts-ignore
- const [deprecation, _] = await getDeprecatedApmIndices(clusterClient, ['foo-*']);
-
- expect(deprecation.level).toEqual('warning');
- expect(deprecation.message).toEqual('APM index requires conversion to 7.x format');
- expect(deprecation.url).toEqual(
- 'https://www.elastic.co/guide/en/apm/get-started/master/apm-release-notes.html'
- );
- expect(deprecation.details).toEqual('This index was created prior to 7.0');
- expect(deprecation.reindex).toBe(true);
- });
-});
-
-describe('isLegacyApmIndex', () => {
- it('is true when for no version', () => {
- expect(isLegacyApmIndex('foo-1', ['foo-*'], {})).toEqual(true);
- });
-
- it('is true when version is less than 7.0.0', () => {
- expect(
- isLegacyApmIndex('foo-1', ['foo-*'], {
- _meta: { version: '6.7.0' },
- })
- ).toEqual(true);
- });
-
- it('is false when version is 7.0.0', () => {
- expect(
- isLegacyApmIndex('foo-1', ['foo-*'], {
- _meta: { version: '7.0.0' },
- })
- ).toEqual(false);
- });
-
- it('is false when version is greater than 7.0.0', () => {
- expect(
- isLegacyApmIndex('foo-1', ['foo-*'], {
- _meta: { version: '7.1.0' },
- })
- ).toEqual(false);
- });
-
- it('is false when using a version qualifier', () => {
- expect(
- isLegacyApmIndex('foo-1', ['foo-*'], {
- _meta: { version: '7.0.0-rc1' },
- })
- ).toEqual(false);
- });
-
- it('handles multiple index patterns', () => {
- expect(
- isLegacyApmIndex('bar-1', ['foo-*', 'bar-*'], {
- _meta: { version: '6.7.0' },
- })
- ).toEqual(true);
-
- expect(
- isLegacyApmIndex('bar-1', ['foo-*', 'bar-*'], {
- _meta: { version: '7.0.0' },
- })
- ).toEqual(false);
- });
-});
diff --git a/x-pack/plugins/upgrade_assistant/server/lib/apm/index.ts b/x-pack/plugins/upgrade_assistant/server/lib/apm/index.ts
deleted file mode 100644
index 8c689df78e555..0000000000000
--- a/x-pack/plugins/upgrade_assistant/server/lib/apm/index.ts
+++ /dev/null
@@ -1,493 +0,0 @@
-/*
- * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
- * or more contributor license agreements. Licensed under the Elastic License
- * 2.0; you may not use this file except in compliance with the Elastic License
- * 2.0.
- */
-
-import { get } from 'lodash';
-import minimatch from 'minimatch';
-import { SemVer, valid } from 'semver';
-import { IScopedClusterClient } from 'src/core/server';
-
-import { EnrichedDeprecationInfo } from '../../../common/types';
-import { FlatSettings } from '../reindexing/types';
-
-export async function getDeprecatedApmIndices(
- clusterClient: IScopedClusterClient,
- indexPatterns: string[] = []
-): Promise {
- const { body: indices } = await clusterClient.asCurrentUser.indices.getMapping({
- index: indexPatterns.join(','),
- // we include @timestamp to prevent filtering mappings without a version
- // since @timestamp is expected to always exist
- filter_path: '*.mappings._meta.version,*.mappings.properties.@timestamp',
- });
-
- return Object.keys(indices).reduce((deprecations: EnrichedDeprecationInfo[], index) => {
- if (isLegacyApmIndex(index, indexPatterns, indices[index].mappings)) {
- deprecations.push({
- level: 'warning',
- message: 'APM index requires conversion to 7.x format',
- url: 'https://www.elastic.co/guide/en/apm/get-started/master/apm-release-notes.html',
- details: 'This index was created prior to 7.0',
- reindex: true,
- index,
- });
- }
-
- return deprecations;
- }, []);
-}
-
-export const isLegacyApmIndex = (
- indexName: string,
- apmIndexPatterns: string[] = [],
- mappings: FlatSettings['mappings']
-) => {
- const defaultValue = '0.0.0';
- const version = get(mappings, '_meta.version', defaultValue);
- const clientVersion = new SemVer(valid(version) ? version : defaultValue);
-
- if (clientVersion.compareMain('7.0.0') > -1) {
- return false;
- }
-
- const find = apmIndexPatterns.find((pattern) => {
- return minimatch(indexName, pattern);
- });
-
- return Boolean(find);
-};
-
-// source: https://github.com/elastic/apm-integration-testing/blob/master/tests/server/test_upgrade.py
-export const apmReindexScript = `
- // add ecs version
- ctx._source.ecs = ['version': '1.1.0-dev'];
-
- // set processor.event
- if (ctx._source.processor == null) {
- // onboarding docs had no processor pre-6.4 - https://github.com/elastic/kibana/issues/52655
- ctx._source.processor = ["event": "onboarding"];
- }
-
- // beat -> observer
- def beat = ctx._source.remove("beat");
- if (beat != null) {
- beat.remove("name");
- ctx._source.observer = beat;
- ctx._source.observer.type = "apm-server";
- }
-
- if (! ctx._source.containsKey("observer")) {
- ctx._source.observer = new HashMap();
- }
-
- // observer.major_version
- ctx._source.observer.version_major = 7;
-
- def listening = ctx._source.remove("listening");
- if (listening != null) {
- ctx._source.observer.listening = listening;
- }
-
- // remove host[.name]
- // clarify if we can simply delete this or it will be set somewhere else in 7.0
- ctx._source.remove("host");
-
- // docker.container -> container
- def docker = ctx._source.remove("docker");
- if (docker != null && docker.containsKey("container")) {
- ctx._source.container = docker.container;
- }
-
- // rip up context
- HashMap context = ctx._source.remove("context");
- if (context != null) {
- // context.process -> process
- def process = context.remove("process");
- if (process != null) {
- def args = process.remove("argv");
- if (args != null) {
- process.args = args;
- }
- ctx._source.process = process;
- }
-
- // context.response -> http.response
- HashMap resp = context.remove("response");
- if (resp != null) {
- if (! ctx._source.containsKey("http")) {
- ctx._source.http = new HashMap();
- }
- ctx._source.http.response = resp;
- }
-
- // context.request -> http & url
- HashMap request = context.remove("request");
- if (request != null) {
- if (! ctx._source.containsKey("http")) {
- ctx._source.http = new HashMap();
- }
-
- // context.request.http_version -> http.version
- def http_version = request.remove("http_version");
- if (http_version != null) {
- ctx._source.http.version = http_version;
- }
-
- if (request.containsKey("headers")) {
- // copy user-agent header
- def ua;
- for (entry in request["headers"].entrySet()) {
- if (entry.getKey().toLowerCase() == "user-agent") {
- ua = entry.getValue();
- }
- }
- if (ua != null) {
- ctx._source.user_agent = new HashMap();
- // setting original and original.text is not possible in painless
- // as original is a keyword in ES template we cannot set it to a HashMap here,
- // so the following is the only possible solution:
- ctx._source.user_agent.original = ua.substring(0, Integer.min(1024, ua.length()));
- }
- }
-
- // context.request.socket -> request.socket
- def socket = request.remove("socket");
- if (socket != null) {
- def add_socket = false;
- def new_socket = new HashMap();
- def remote_address = socket.remove("remote_address");
- if (remote_address != null) {
- add_socket = true;
- new_socket.remote_address = remote_address;
- }
- def encrypted = socket.remove("encrypted");
- if (encrypted != null) {
- add_socket = true;
- new_socket.encrypted = encrypted;
- }
- if (add_socket) {
- request.socket = new_socket;
- }
- }
-
- // context.request.url -> url
- HashMap url = request.remove("url");
- def fragment = url.remove("hash");
- if (fragment != null) {
- url.fragment = fragment;
- }
- def domain = url.remove("hostname");
- if (domain != null) {
- url.domain = domain;
- }
- def path = url.remove("pathname");
- if (path != null) {
- url.path = path;
- }
- def scheme = url.remove("protocol");
- if (scheme != null) {
- def end = scheme.lastIndexOf(":");
- if (end > -1) {
- scheme = scheme.substring(0, end);
- }
- url.scheme = scheme
- }
- def original = url.remove("raw");
- if (original != null) {
- url.original = original;
- }
- def port = url.remove("port");
- if (port != null) {
- try {
- int portNum = Integer.parseInt(port);
- url.port = portNum;
- } catch (Exception e) {
- // toss port
- }
- }
- def query = url.remove("search");
- if (query != null) {
- url.query = query;
- }
- ctx._source.url = url;
-
- // restore what is left of request, under http
-
- def body = request.remove("body");
-
- ctx._source.http.request = request;
- ctx._source.http.request.method = ctx._source.http.request.method?.toLowerCase();
-
- // context.request.body -> http.request.body.original
- if (body != null) {
- ctx._source.http.request.body = new HashMap();
- ctx._source.http.request.body.original = body;
- }
- }
-
- // bump timestamp.us by span.start.us for spans
- // shouldn't @timestamp this already be a Date?
- if (ctx._source.processor.event == "span" && context.service.agent.name == "js-base"){
- def ts = ctx._source.get("@timestamp");
- if (ts != null && !ctx._source.containsKey("timestamp") && ctx._source.span.start.containsKey("us")) {
- // add span.start to @timestamp for rum documents v1
- ctx._source.timestamp = new HashMap();
- def tsms = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSS'Z'").parse(ts).getTime();
- ctx._source['@timestamp'] = Instant.ofEpochMilli(tsms + (ctx._source.span.start.us/1000));
- ctx._source.timestamp.us = (tsms*1000) + ctx._source.span.start.us;
- }
- }
-
- // context.service.agent -> agent
- HashMap service = context.remove("service");
- ctx._source.agent = service.remove("agent");
-
- // context.service -> service
- ctx._source.service = service;
-
- // context.system -> host
- def system = context.remove("system");
- if (system != null) {
- system.os = new HashMap();
- system.os.platform = system.remove("platform");
- ctx._source.host = system;
- }
-
- // context.tags -> labels
- def tags = context.remove("tags");
- if (tags != null) {
- ctx._source.labels = tags;
- }
-
- // context.user -> user & user_agent
- if (context.containsKey("user")) {
- HashMap user = context.remove("user");
- // user.username -> user.name
- def username = user.remove("username");
- if (username != null) {
- user.name = username;
- }
-
- // context.user.ip -> client.ip
- def userip = user.remove("ip");
- if (userip != null) {
- ctx._source.client = new HashMap();
- ctx._source.client.ip = userip;
- }
-
- // move user-agent info
- // this will overwrite the value from http.request.headers if set
- def ua = user.remove("user-agent");
- if (ua != null) {
- ctx._source.user_agent = new HashMap();
- // setting original and original.text is not possible in painless
- // as original is a keyword in ES template we cannot set it to a HashMap here,
- // so the following is the only possible solution:
- ctx._source.user_agent.original = ua.substring(0, Integer.min(1024, ua.length()));
- }
-
- def pua = user.remove("user_agent");
- if (pua != null) {
- if (ctx._source.user_agent == null){
- ctx._source.user_agent = new HashMap();
- }
- def os = pua.remove("os");
- def osminor = pua.remove("os_minor");
- def osmajor = pua.remove("os_major");
- def osname = pua.remove("os_name");
-
- def newos = new HashMap();
- if (os != null){
- newos.full = os;
- }
- if (osmajor != null || osminor != null){
- newos.version = osmajor + "." + osminor;
- }
- if (osname != null){
- newos.name = osname;
- }
- ctx._source.user_agent.os = newos;
-
- def device = pua.remove("device");
- if (device != null){
- ctx._source.user_agent.device = new HashMap();
- ctx._source.user_agent.device.name = device;
- }
- // not exactly reflecting 7.0, but the closes we can get
- def major = pua.remove("major");
- if (major != null){
- def version = major;
- def minor = pua.remove("minor");
- if (minor != null){
- version += "." + minor;
- def patch = pua.remove("patch");
- if (patch != null){
- version += "." + patch
- }
- }
- ctx._source.user_agent.version = version;
- }
- }
-
- // remove unknown fields from user, like is_authenticated
- def add_user = false;
- def new_user = new HashMap();
- def email = user.remove("email");
- if (email != null) {
- add_user = true;
- new_user.email = email;
- }
- def id = user.remove("id");
- if (id != null) {
- add_user = true;
- new_user.id = String.valueOf(id);
- }
- def name = user.remove("name");
- if (name != null) {
- add_user = true;
- new_user.name = name;
- }
- if (add_user) {
- ctx._source.user = new_user;
- }
- }
-
- // context.custom -> error,transaction,span.custom
- def custom = context.remove("custom");
- if (custom != null) {
- if (ctx._source.processor.event == "span") {
- ctx._source.span.custom = custom;
- } else if (ctx._source.processor.event == "transaction") {
- ctx._source.transaction.custom = custom;
- } else if (ctx._source.processor.event == "error") {
- ctx._source.error.custom = custom;
- }
- }
-
- // context.page -> error.page,transaction.page
- def page = context.remove("page");
- if (page != null) {
- if (ctx._source.processor.event == "transaction") {
- ctx._source.transaction.page = page;
- } else if (ctx._source.processor.event == "error") {
- ctx._source.error.page = page;
- }
- }
-
- // context.db -> span.db
- def db = context.remove("db");
- if (db != null) {
- def db_user = db.remove("user");
- if (db_user != null) {
- db.user = ["name": db_user];
- }
- ctx._source.span.db = db;
- }
-
- // context.http -> span.http
- def http = context.remove("http");
- if (http != null) {
- // context.http.url -> span.http.url.original
- def url = http.remove("url");
- if (url != null) {
- http.url = ["original": url];
- }
- // context.http.status_code -> span.http.response.status_code
- def status_code = http.remove("status_code");
- if (status_code != null) {
- http.response = ["status_code": status_code];
- }
- // lowercase span.http.method
- if (http.containsKey("method")) {
- http.method = http.method.toLowerCase();
- }
- ctx._source.span.http = http;
- }
- }
-
- // per https://github.com/elastic/apm/issues/21
- // if kubernetes.node.name is set, copy it to host.hostname
- // else if other kubernetes.* is set, remove host.hostname
- // else leave it alone
- // relies on system.hostname -> host.hostname already happening earlier in this script
- if (ctx._source.kubernetes?.node?.name != null) {
- if (! ctx._source.containsKey("host")) {
- ctx._source.host = new HashMap();
- }
- ctx._source.host.hostname = ctx._source.kubernetes.node.name;
- } else if (ctx._source.containsKey("kubernetes")) {
- if (ctx._source.host?.hostname != null) {
- ctx._source.host.remove("hostname");
- }
- }
-
- if (ctx._source.processor.event == "span") {
- def hex_id = ctx._source.span.remove("hex_id");
- def span_id = ctx._source.span.remove("id");
- if (hex_id != null) {
- ctx._source.span.id = hex_id;
- } else if (span_id != null){
- ctx._source.span.id = span_id.toString();
- }
- def parent = ctx._source.span.remove("parent");
- def tr_id = ctx._source.transaction.get("id");
- if (ctx._source.parent == null) {
- if (parent != null) {
- ctx._source.parent = ["id": parent.toString()];
- } else if (tr_id != null) {
- // 7.x UI requires a value for parent.id - https://github.com/elastic/kibana/issues/52763
- ctx._source.parent = ["id": tr_id];
- }
- }
- }
-
- // create trace.id
- if (ctx._source.processor.event == "transaction" || ctx._source.processor.event == "span" || ctx._source.processor.event == "error") {
- if (ctx._source.containsKey("transaction")) {
- def tr_id = ctx._source.transaction.get("id");
- if (ctx._source.trace == null && tr_id != null) {
- // create a trace id from the transaction.id
- // v1 transaction.id was a UUID, should have 122 random bits or so
- ctx._source.trace = new HashMap();
- ctx._source.trace.id = tr_id.replace("-", "");
- }
- }
-
- // create timestamp.us from @timestamp
- def ts = ctx._source.get("@timestamp");
- if (ts != null && !ctx._source.containsKey("timestamp")) {
- //set timestamp.microseconds to @timestamp
- ctx._source.timestamp = new HashMap();
- ctx._source.timestamp.us = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSS'Z'").parse(ts).getTime()*1000;
- }
-
- }
-
- // transaction.span_count.dropped.total -> transaction.span_count.dropped
- if (ctx._source.processor.event == "transaction") {
- // transaction.span_count.dropped.total -> transaction.span_count.dropped
- if (ctx._source.transaction.containsKey("span_count")) {
- def dropped = ctx._source.transaction.span_count.remove("dropped");
- if (dropped != null) {
- ctx._source.transaction.span_count.dropped = dropped.total;
- }
- }
- }
-
- if (ctx._source.processor.event == "error") {
- // culprit is now a keyword, so trim it down to 1024 chars
- def culprit = ctx._source.error.remove("culprit");
- if (culprit != null) {
- ctx._source.error.culprit = culprit.substring(0, Integer.min(1024, culprit.length()));
- }
-
- // error.exception is now a list (exception chain)
- def exception = ctx._source.error.remove("exception");
- if (exception != null) {
- ctx._source.error.exception = [exception];
- }
- }
-`;
diff --git a/x-pack/plugins/upgrade_assistant/server/lib/apm/mapping.json b/x-pack/plugins/upgrade_assistant/server/lib/apm/mapping.json
deleted file mode 100644
index f518b824f1108..0000000000000
--- a/x-pack/plugins/upgrade_assistant/server/lib/apm/mapping.json
+++ /dev/null
@@ -1,1598 +0,0 @@
-{
- "_meta": {
- "beat": "apm",
- "version": "7.0.0"
- },
- "date_detection": false,
- "dynamic_templates": [
- {
- "container.labels": {
- "mapping": {
- "type": "keyword"
- },
- "match_mapping_type": "string",
- "path_match": "container.labels.*"
- }
- },
- {
- "fields": {
- "mapping": {
- "type": "keyword"
- },
- "match_mapping_type": "string",
- "path_match": "fields.*"
- }
- },
- {
- "docker.container.labels": {
- "mapping": {
- "type": "keyword"
- },
- "match_mapping_type": "string",
- "path_match": "docker.container.labels.*"
- }
- },
- {
- "labels": {
- "mapping": {
- "type": "keyword"
- },
- "match_mapping_type": "string",
- "path_match": "labels.*"
- }
- },
- {
- "labels": {
- "mapping": {
- "type": "boolean"
- },
- "match_mapping_type": "boolean",
- "path_match": "labels.*"
- }
- },
- {
- "labels": {
- "mapping": {
- "scaling_factor": 1000000,
- "type": "scaled_float"
- },
- "match_mapping_type": "*",
- "path_match": "labels.*"
- }
- },
- {
- "transaction.marks": {
- "mapping": {
- "type": "keyword"
- },
- "match_mapping_type": "string",
- "path_match": "transaction.marks.*"
- }
- },
- {
- "transaction.marks.*.*": {
- "mapping": {
- "scaling_factor": 1000000,
- "type": "scaled_float"
- },
- "match_mapping_type": "*",
- "path_match": "transaction.marks.*.*"
- }
- },
- {
- "strings_as_keyword": {
- "mapping": {
- "ignore_above": 1024,
- "type": "keyword"
- },
- "match_mapping_type": "string"
- }
- }
- ],
- "properties": {
- "@timestamp": {
- "type": "date"
- },
- "agent": {
- "dynamic": false,
- "properties": {
- "ephemeral_id": {
- "ignore_above": 1024,
- "type": "keyword"
- },
- "hostname": {
- "ignore_above": 1024,
- "type": "keyword"
- },
- "id": {
- "ignore_above": 1024,
- "type": "keyword"
- },
- "name": {
- "ignore_above": 1024,
- "type": "keyword"
- },
- "type": {
- "ignore_above": 1024,
- "type": "keyword"
- },
- "version": {
- "ignore_above": 1024,
- "type": "keyword"
- }
- }
- },
- "client": {
- "dynamic": false,
- "properties": {
- "address": {
- "ignore_above": 1024,
- "type": "keyword"
- },
- "bytes": {
- "type": "long"
- },
- "domain": {
- "ignore_above": 1024,
- "type": "keyword"
- },
- "geo": {
- "properties": {
- "city_name": {
- "ignore_above": 1024,
- "type": "keyword"
- },
- "continent_name": {
- "ignore_above": 1024,
- "type": "keyword"
- },
- "country_iso_code": {
- "ignore_above": 1024,
- "type": "keyword"
- },
- "country_name": {
- "ignore_above": 1024,
- "type": "keyword"
- },
- "location": {
- "type": "geo_point"
- },
- "name": {
- "ignore_above": 1024,
- "type": "keyword"
- },
- "region_iso_code": {
- "ignore_above": 1024,
- "type": "keyword"
- },
- "region_name": {
- "ignore_above": 1024,
- "type": "keyword"
- }
- }
- },
- "ip": {
- "type": "ip"
- },
- "mac": {
- "ignore_above": 1024,
- "type": "keyword"
- },
- "packets": {
- "type": "long"
- },
- "port": {
- "type": "long"
- }
- }
- },
- "cloud": {
- "properties": {
- "account": {
- "properties": {
- "id": {
- "ignore_above": 1024,
- "type": "keyword"
- }
- }
- },
- "availability_zone": {
- "ignore_above": 1024,
- "type": "keyword"
- },
- "instance": {
- "properties": {
- "id": {
- "ignore_above": 1024,
- "type": "keyword"
- },
- "name": {
- "ignore_above": 1024,
- "type": "keyword"
- }
- }
- },
- "machine": {
- "properties": {
- "type": {
- "ignore_above": 1024,
- "type": "keyword"
- }
- }
- },
- "project": {
- "properties": {
- "id": {
- "ignore_above": 1024,
- "type": "keyword"
- }
- }
- },
- "provider": {
- "ignore_above": 1024,
- "type": "keyword"
- },
- "region": {
- "ignore_above": 1024,
- "type": "keyword"
- }
- }
- },
- "container": {
- "dynamic": false,
- "properties": {
- "id": {
- "ignore_above": 1024,
- "type": "keyword"
- },
- "image": {
- "properties": {
- "name": {
- "ignore_above": 1024,
- "type": "keyword"
- },
- "tag": {
- "ignore_above": 1024,
- "type": "keyword"
- }
- }
- },
- "labels": {
- "type": "object"
- },
- "name": {
- "ignore_above": 1024,
- "type": "keyword"
- },
- "runtime": {
- "ignore_above": 1024,
- "type": "keyword"
- }
- }
- },
- "destination": {
- "properties": {
- "address": {
- "ignore_above": 1024,
- "type": "keyword"
- },
- "bytes": {
- "type": "long"
- },
- "domain": {
- "ignore_above": 1024,
- "type": "keyword"
- },
- "geo": {
- "properties": {
- "city_name": {
- "ignore_above": 1024,
- "type": "keyword"
- },
- "continent_name": {
- "ignore_above": 1024,
- "type": "keyword"
- },
- "country_iso_code": {
- "ignore_above": 1024,
- "type": "keyword"
- },
- "country_name": {
- "ignore_above": 1024,
- "type": "keyword"
- },
- "location": {
- "type": "geo_point"
- },
- "name": {
- "ignore_above": 1024,
- "type": "keyword"
- },
- "region_iso_code": {
- "ignore_above": 1024,
- "type": "keyword"
- },
- "region_name": {
- "ignore_above": 1024,
- "type": "keyword"
- }
- }
- },
- "ip": {
- "type": "ip"
- },
- "mac": {
- "ignore_above": 1024,
- "type": "keyword"
- },
- "packets": {
- "type": "long"
- },
- "port": {
- "type": "long"
- }
- }
- },
- "docker": {
- "properties": {
- "container": {
- "properties": {
- "labels": {
- "type": "object"
- }
- }
- }
- }
- },
- "ecs": {
- "properties": {
- "version": {
- "ignore_above": 1024,
- "type": "keyword"
- }
- }
- },
- "error": {
- "dynamic": false,
- "properties": {
- "code": {
- "ignore_above": 1024,
- "type": "keyword"
- },
- "culprit": {
- "ignore_above": 1024,
- "type": "keyword"
- },
- "exception": {
- "properties": {
- "code": {
- "ignore_above": 1024,
- "type": "keyword"
- },
- "handled": {
- "type": "boolean"
- },
- "message": {
- "norms": false,
- "type": "text"
- },
- "module": {
- "ignore_above": 1024,
- "type": "keyword"
- },
- "type": {
- "ignore_above": 1024,
- "type": "keyword"
- }
- }
- },
- "grouping_key": {
- "ignore_above": 1024,
- "type": "keyword"
- },
- "id": {
- "ignore_above": 1024,
- "type": "keyword"
- },
- "log": {
- "properties": {
- "level": {
- "ignore_above": 1024,
- "type": "keyword"
- },
- "logger_name": {
- "ignore_above": 1024,
- "type": "keyword"
- },
- "message": {
- "norms": false,
- "type": "text"
- },
- "param_message": {
- "ignore_above": 1024,
- "type": "keyword"
- }
- }
- },
- "message": {
- "norms": false,
- "type": "text"
- },
- "type": {
- "ignore_above": 1024,
- "type": "keyword"
- }
- }
- },
- "event": {
- "properties": {
- "action": {
- "ignore_above": 1024,
- "type": "keyword"
- },
- "category": {
- "ignore_above": 1024,
- "type": "keyword"
- },
- "created": {
- "type": "date"
- },
- "dataset": {
- "ignore_above": 1024,
- "type": "keyword"
- },
- "duration": {
- "type": "long"
- },
- "end": {
- "type": "date"
- },
- "hash": {
- "ignore_above": 1024,
- "type": "keyword"
- },
- "id": {
- "ignore_above": 1024,
- "type": "keyword"
- },
- "kind": {
- "ignore_above": 1024,
- "type": "keyword"
- },
- "module": {
- "ignore_above": 1024,
- "type": "keyword"
- },
- "original": {
- "doc_values": false,
- "ignore_above": 1024,
- "index": false,
- "type": "keyword"
- },
- "outcome": {
- "ignore_above": 1024,
- "type": "keyword"
- },
- "risk_score": {
- "type": "float"
- },
- "risk_score_norm": {
- "type": "float"
- },
- "severity": {
- "type": "long"
- },
- "start": {
- "type": "date"
- },
- "timezone": {
- "ignore_above": 1024,
- "type": "keyword"
- },
- "type": {
- "ignore_above": 1024,
- "type": "keyword"
- }
- }
- },
- "fields": {
- "type": "object"
- },
- "file": {
- "properties": {
- "ctime": {
- "type": "date"
- },
- "device": {
- "ignore_above": 1024,
- "type": "keyword"
- },
- "extension": {
- "ignore_above": 1024,
- "type": "keyword"
- },
- "gid": {
- "ignore_above": 1024,
- "type": "keyword"
- },
- "group": {
- "ignore_above": 1024,
- "type": "keyword"
- },
- "inode": {
- "ignore_above": 1024,
- "type": "keyword"
- },
- "mode": {
- "ignore_above": 1024,
- "type": "keyword"
- },
- "mtime": {
- "type": "date"
- },
- "owner": {
- "ignore_above": 1024,
- "type": "keyword"
- },
- "path": {
- "ignore_above": 1024,
- "type": "keyword"
- },
- "size": {
- "type": "long"
- },
- "target_path": {
- "ignore_above": 1024,
- "type": "keyword"
- },
- "type": {
- "ignore_above": 1024,
- "type": "keyword"
- },
- "uid": {
- "ignore_above": 1024,
- "type": "keyword"
- }
- }
- },
- "group": {
- "properties": {
- "id": {
- "ignore_above": 1024,
- "type": "keyword"
- },
- "name": {
- "ignore_above": 1024,
- "type": "keyword"
- }
- }
- },
- "host": {
- "dynamic": false,
- "properties": {
- "architecture": {
- "ignore_above": 1024,
- "type": "keyword"
- },
- "geo": {
- "properties": {
- "city_name": {
- "ignore_above": 1024,
- "type": "keyword"
- },
- "continent_name": {
- "ignore_above": 1024,
- "type": "keyword"
- },
- "country_iso_code": {
- "ignore_above": 1024,
- "type": "keyword"
- },
- "country_name": {
- "ignore_above": 1024,
- "type": "keyword"
- },
- "location": {
- "type": "geo_point"
- },
- "name": {
- "ignore_above": 1024,
- "type": "keyword"
- },
- "region_iso_code": {
- "ignore_above": 1024,
- "type": "keyword"
- },
- "region_name": {
- "ignore_above": 1024,
- "type": "keyword"
- }
- }
- },
- "hostname": {
- "ignore_above": 1024,
- "type": "keyword"
- },
- "id": {
- "ignore_above": 1024,
- "type": "keyword"
- },
- "ip": {
- "type": "ip"
- },
- "mac": {
- "ignore_above": 1024,
- "type": "keyword"
- },
- "name": {
- "ignore_above": 1024,
- "type": "keyword"
- },
- "os": {
- "properties": {
- "family": {
- "ignore_above": 1024,
- "type": "keyword"
- },
- "full": {
- "ignore_above": 1024,
- "type": "keyword"
- },
- "kernel": {
- "ignore_above": 1024,
- "type": "keyword"
- },
- "name": {
- "ignore_above": 1024,
- "type": "keyword"
- },
- "platform": {
- "ignore_above": 1024,
- "type": "keyword"
- },
- "version": {
- "ignore_above": 1024,
- "type": "keyword"
- }
- }
- },
- "type": {
- "ignore_above": 1024,
- "type": "keyword"
- }
- }
- },
- "http": {
- "dynamic": false,
- "properties": {
- "request": {
- "properties": {
- "body": {
- "properties": {
- "bytes": {
- "type": "long"
- },
- "content": {
- "ignore_above": 1024,
- "type": "keyword"
- }
- }
- },
- "bytes": {
- "type": "long"
- },
- "method": {
- "ignore_above": 1024,
- "type": "keyword"
- },
- "referrer": {
- "ignore_above": 1024,
- "type": "keyword"
- }
- }
- },
- "response": {
- "properties": {
- "body": {
- "properties": {
- "bytes": {
- "type": "long"
- },
- "content": {
- "ignore_above": 1024,
- "type": "keyword"
- }
- }
- },
- "bytes": {
- "type": "long"
- },
- "finished": {
- "type": "boolean"
- },
- "status_code": {
- "type": "long"
- }
- }
- },
- "version": {
- "ignore_above": 1024,
- "type": "keyword"
- }
- }
- },
- "kubernetes": {
- "dynamic": false,
- "properties": {
- "annotations": {
- "type": "object"
- },
- "container": {
- "properties": {
- "image": {
- "ignore_above": 1024,
- "type": "keyword"
- },
- "name": {
- "ignore_above": 1024,
- "type": "keyword"
- }
- }
- },
- "labels": {
- "type": "object"
- },
- "namespace": {
- "ignore_above": 1024,
- "type": "keyword"
- },
- "node": {
- "properties": {
- "name": {
- "ignore_above": 1024,
- "type": "keyword"
- }
- }
- },
- "pod": {
- "properties": {
- "name": {
- "ignore_above": 1024,
- "type": "keyword"
- },
- "uid": {
- "ignore_above": 1024,
- "type": "keyword"
- }
- }
- }
- }
- },
- "labels": {
- "dynamic": true,
- "type": "object"
- },
- "log": {
- "properties": {
- "level": {
- "ignore_above": 1024,
- "type": "keyword"
- },
- "original": {
- "doc_values": false,
- "ignore_above": 1024,
- "index": false,
- "type": "keyword"
- }
- }
- },
- "message": {
- "norms": false,
- "type": "text"
- },
- "network": {
- "properties": {
- "application": {
- "ignore_above": 1024,
- "type": "keyword"
- },
- "bytes": {
- "type": "long"
- },
- "community_id": {
- "ignore_above": 1024,
- "type": "keyword"
- },
- "direction": {
- "ignore_above": 1024,
- "type": "keyword"
- },
- "forwarded_ip": {
- "type": "ip"
- },
- "iana_number": {
- "ignore_above": 1024,
- "type": "keyword"
- },
- "name": {
- "ignore_above": 1024,
- "type": "keyword"
- },
- "packets": {
- "type": "long"
- },
- "protocol": {
- "ignore_above": 1024,
- "type": "keyword"
- },
- "transport": {
- "ignore_above": 1024,
- "type": "keyword"
- },
- "type": {
- "ignore_above": 1024,
- "type": "keyword"
- }
- }
- },
- "observer": {
- "dynamic": false,
- "properties": {
- "geo": {
- "properties": {
- "city_name": {
- "ignore_above": 1024,
- "type": "keyword"
- },
- "continent_name": {
- "ignore_above": 1024,
- "type": "keyword"
- },
- "country_iso_code": {
- "ignore_above": 1024,
- "type": "keyword"
- },
- "country_name": {
- "ignore_above": 1024,
- "type": "keyword"
- },
- "location": {
- "type": "geo_point"
- },
- "name": {
- "ignore_above": 1024,
- "type": "keyword"
- },
- "region_iso_code": {
- "ignore_above": 1024,
- "type": "keyword"
- },
- "region_name": {
- "ignore_above": 1024,
- "type": "keyword"
- }
- }
- },
- "hostname": {
- "ignore_above": 1024,
- "type": "keyword"
- },
- "ip": {
- "type": "ip"
- },
- "listening": {
- "ignore_above": 1024,
- "type": "keyword"
- },
- "mac": {
- "ignore_above": 1024,
- "type": "keyword"
- },
- "os": {
- "properties": {
- "family": {
- "ignore_above": 1024,
- "type": "keyword"
- },
- "full": {
- "ignore_above": 1024,
- "type": "keyword"
- },
- "kernel": {
- "ignore_above": 1024,
- "type": "keyword"
- },
- "name": {
- "ignore_above": 1024,
- "type": "keyword"
- },
- "platform": {
- "ignore_above": 1024,
- "type": "keyword"
- },
- "version": {
- "ignore_above": 1024,
- "type": "keyword"
- }
- }
- },
- "serial_number": {
- "ignore_above": 1024,
- "type": "keyword"
- },
- "type": {
- "ignore_above": 1024,
- "type": "keyword"
- },
- "vendor": {
- "ignore_above": 1024,
- "type": "keyword"
- },
- "version": {
- "ignore_above": 1024,
- "type": "keyword"
- },
- "version_major": {
- "type": "byte"
- }
- }
- },
- "organization": {
- "properties": {
- "id": {
- "ignore_above": 1024,
- "type": "keyword"
- },
- "name": {
- "ignore_above": 1024,
- "type": "keyword"
- }
- }
- },
- "os": {
- "properties": {
- "family": {
- "ignore_above": 1024,
- "type": "keyword"
- },
- "full": {
- "ignore_above": 1024,
- "type": "keyword"
- },
- "kernel": {
- "ignore_above": 1024,
- "type": "keyword"
- },
- "name": {
- "ignore_above": 1024,
- "type": "keyword"
- },
- "platform": {
- "ignore_above": 1024,
- "type": "keyword"
- },
- "version": {
- "ignore_above": 1024,
- "type": "keyword"
- }
- }
- },
- "parent": {
- "dynamic": false,
- "properties": {
- "id": {
- "ignore_above": 1024,
- "type": "keyword"
- }
- }
- },
- "process": {
- "dynamic": false,
- "properties": {
- "args": {
- "ignore_above": 1024,
- "type": "keyword"
- },
- "executable": {
- "ignore_above": 1024,
- "type": "keyword"
- },
- "name": {
- "ignore_above": 1024,
- "type": "keyword"
- },
- "pid": {
- "type": "long"
- },
- "ppid": {
- "type": "long"
- },
- "start": {
- "type": "date"
- },
- "thread": {
- "properties": {
- "id": {
- "type": "long"
- }
- }
- },
- "title": {
- "ignore_above": 1024,
- "type": "keyword"
- },
- "working_directory": {
- "ignore_above": 1024,
- "type": "keyword"
- }
- }
- },
- "processor": {
- "properties": {
- "event": {
- "ignore_above": 1024,
- "type": "keyword"
- },
- "name": {
- "ignore_above": 1024,
- "type": "keyword"
- }
- }
- },
- "related": {
- "properties": {
- "ip": {
- "type": "ip"
- }
- }
- },
- "server": {
- "properties": {
- "address": {
- "ignore_above": 1024,
- "type": "keyword"
- },
- "bytes": {
- "type": "long"
- },
- "domain": {
- "ignore_above": 1024,
- "type": "keyword"
- },
- "geo": {
- "properties": {
- "city_name": {
- "ignore_above": 1024,
- "type": "keyword"
- },
- "continent_name": {
- "ignore_above": 1024,
- "type": "keyword"
- },
- "country_iso_code": {
- "ignore_above": 1024,
- "type": "keyword"
- },
- "country_name": {
- "ignore_above": 1024,
- "type": "keyword"
- },
- "location": {
- "type": "geo_point"
- },
- "name": {
- "ignore_above": 1024,
- "type": "keyword"
- },
- "region_iso_code": {
- "ignore_above": 1024,
- "type": "keyword"
- },
- "region_name": {
- "ignore_above": 1024,
- "type": "keyword"
- }
- }
- },
- "ip": {
- "type": "ip"
- },
- "mac": {
- "ignore_above": 1024,
- "type": "keyword"
- },
- "packets": {
- "type": "long"
- },
- "port": {
- "type": "long"
- }
- }
- },
- "service": {
- "dynamic": false,
- "properties": {
- "environment": {
- "ignore_above": 1024,
- "type": "keyword"
- },
- "ephemeral_id": {
- "ignore_above": 1024,
- "type": "keyword"
- },
- "framework": {
- "properties": {
- "name": {
- "ignore_above": 1024,
- "type": "keyword"
- },
- "version": {
- "ignore_above": 1024,
- "type": "keyword"
- }
- }
- },
- "id": {
- "ignore_above": 1024,
- "type": "keyword"
- },
- "language": {
- "properties": {
- "name": {
- "ignore_above": 1024,
- "type": "keyword"
- },
- "version": {
- "ignore_above": 1024,
- "type": "keyword"
- }
- }
- },
- "name": {
- "ignore_above": 1024,
- "type": "keyword"
- },
- "runtime": {
- "properties": {
- "name": {
- "ignore_above": 1024,
- "type": "keyword"
- },
- "version": {
- "ignore_above": 1024,
- "type": "keyword"
- }
- }
- },
- "state": {
- "ignore_above": 1024,
- "type": "keyword"
- },
- "type": {
- "ignore_above": 1024,
- "type": "keyword"
- },
- "version": {
- "ignore_above": 1024,
- "type": "keyword"
- }
- }
- },
- "source": {
- "properties": {
- "address": {
- "ignore_above": 1024,
- "type": "keyword"
- },
- "bytes": {
- "type": "long"
- },
- "domain": {
- "ignore_above": 1024,
- "type": "keyword"
- },
- "geo": {
- "properties": {
- "city_name": {
- "ignore_above": 1024,
- "type": "keyword"
- },
- "continent_name": {
- "ignore_above": 1024,
- "type": "keyword"
- },
- "country_iso_code": {
- "ignore_above": 1024,
- "type": "keyword"
- },
- "country_name": {
- "ignore_above": 1024,
- "type": "keyword"
- },
- "location": {
- "type": "geo_point"
- },
- "name": {
- "ignore_above": 1024,
- "type": "keyword"
- },
- "region_iso_code": {
- "ignore_above": 1024,
- "type": "keyword"
- },
- "region_name": {
- "ignore_above": 1024,
- "type": "keyword"
- }
- }
- },
- "ip": {
- "type": "ip"
- },
- "mac": {
- "ignore_above": 1024,
- "type": "keyword"
- },
- "packets": {
- "type": "long"
- },
- "port": {
- "type": "long"
- }
- }
- },
- "sourcemap": {
- "dynamic": false,
- "properties": {
- "bundle_filepath": {
- "ignore_above": 1024,
- "type": "keyword"
- },
- "service": {
- "properties": {
- "name": {
- "ignore_above": 1024,
- "type": "keyword"
- },
- "version": {
- "ignore_above": 1024,
- "type": "keyword"
- }
- }
- }
- }
- },
- "span": {
- "dynamic": false,
- "properties": {
- "action": {
- "ignore_above": 1024,
- "type": "keyword"
- },
- "duration": {
- "properties": {
- "us": {
- "type": "long"
- }
- }
- },
- "id": {
- "ignore_above": 1024,
- "type": "keyword"
- },
- "name": {
- "ignore_above": 1024,
- "type": "keyword"
- },
- "start": {
- "properties": {
- "us": {
- "type": "long"
- }
- }
- },
- "subtype": {
- "ignore_above": 1024,
- "type": "keyword"
- },
- "sync": {
- "type": "boolean"
- },
- "type": {
- "ignore_above": 1024,
- "type": "keyword"
- }
- }
- },
- "system": {
- "properties": {
- "cpu": {
- "properties": {
- "total": {
- "properties": {
- "norm": {
- "properties": {
- "pct": {
- "scaling_factor": 1000,
- "type": "scaled_float"
- }
- }
- }
- }
- }
- }
- },
- "memory": {
- "properties": {
- "actual": {
- "properties": {
- "free": {
- "type": "long"
- }
- }
- },
- "total": {
- "type": "long"
- }
- }
- },
- "process": {
- "properties": {
- "cpu": {
- "properties": {
- "total": {
- "properties": {
- "norm": {
- "properties": {
- "pct": {
- "scaling_factor": 1000,
- "type": "scaled_float"
- }
- }
- }
- }
- }
- }
- },
- "memory": {
- "properties": {
- "rss": {
- "properties": {
- "bytes": {
- "type": "long"
- }
- }
- },
- "size": {
- "type": "long"
- }
- }
- }
- }
- }
- }
- },
- "tags": {
- "ignore_above": 1024,
- "type": "keyword"
- },
- "timestamp": {
- "properties": {
- "us": {
- "type": "long"
- }
- }
- },
- "trace": {
- "dynamic": false,
- "properties": {
- "id": {
- "ignore_above": 1024,
- "type": "keyword"
- }
- }
- },
- "transaction": {
- "dynamic": false,
- "properties": {
- "duration": {
- "properties": {
- "us": {
- "type": "long"
- }
- }
- },
- "id": {
- "ignore_above": 1024,
- "type": "keyword"
- },
- "marks": {
- "dynamic": true,
- "properties": {
- "*": {
- "properties": {
- "*": {
- "dynamic": true,
- "type": "object"
- }
- }
- }
- },
- "type": "object"
- },
- "name": {
- "fields": {
- "text": {
- "norms": false,
- "type": "text"
- }
- },
- "ignore_above": 1024,
- "type": "keyword"
- },
- "result": {
- "ignore_above": 1024,
- "type": "keyword"
- },
- "sampled": {
- "type": "boolean"
- },
- "span_count": {
- "properties": {
- "dropped": {
- "type": "long"
- }
- }
- },
- "type": {
- "ignore_above": 1024,
- "type": "keyword"
- }
- }
- },
- "url": {
- "dynamic": false,
- "properties": {
- "domain": {
- "ignore_above": 1024,
- "type": "keyword"
- },
- "fragment": {
- "ignore_above": 1024,
- "type": "keyword"
- },
- "full": {
- "ignore_above": 1024,
- "type": "keyword"
- },
- "original": {
- "ignore_above": 1024,
- "type": "keyword"
- },
- "password": {
- "ignore_above": 1024,
- "type": "keyword"
- },
- "path": {
- "ignore_above": 1024,
- "type": "keyword"
- },
- "port": {
- "type": "long"
- },
- "query": {
- "ignore_above": 1024,
- "type": "keyword"
- },
- "scheme": {
- "ignore_above": 1024,
- "type": "keyword"
- },
- "username": {
- "ignore_above": 1024,
- "type": "keyword"
- }
- }
- },
- "user": {
- "dynamic": false,
- "properties": {
- "email": {
- "ignore_above": 1024,
- "type": "keyword"
- },
- "full_name": {
- "ignore_above": 1024,
- "type": "keyword"
- },
- "group": {
- "properties": {
- "id": {
- "ignore_above": 1024,
- "type": "keyword"
- },
- "name": {
- "ignore_above": 1024,
- "type": "keyword"
- }
- }
- },
- "hash": {
- "ignore_above": 1024,
- "type": "keyword"
- },
- "id": {
- "ignore_above": 1024,
- "type": "keyword"
- },
- "name": {
- "ignore_above": 1024,
- "type": "keyword"
- }
- }
- },
- "user_agent": {
- "dynamic": false,
- "properties": {
- "device": {
- "properties": {
- "name": {
- "ignore_above": 1024,
- "type": "keyword"
- }
- }
- },
- "name": {
- "ignore_above": 1024,
- "type": "keyword"
- },
- "original": {
- "fields": {
- "text": {
- "norms": false,
- "type": "text"
- }
- },
- "ignore_above": 1024,
- "type": "keyword"
- },
- "os": {
- "properties": {
- "family": {
- "ignore_above": 1024,
- "type": "keyword"
- },
- "full": {
- "ignore_above": 1024,
- "type": "keyword"
- },
- "kernel": {
- "ignore_above": 1024,
- "type": "keyword"
- },
- "name": {
- "ignore_above": 1024,
- "type": "keyword"
- },
- "platform": {
- "ignore_above": 1024,
- "type": "keyword"
- },
- "version": {
- "ignore_above": 1024,
- "type": "keyword"
- }
- }
- },
- "version": {
- "ignore_above": 1024,
- "type": "keyword"
- }
- }
- },
- "view spans": {
- "ignore_above": 1024,
- "type": "keyword"
- }
- }
-}
diff --git a/x-pack/plugins/upgrade_assistant/server/lib/es_migration_apis.ts b/x-pack/plugins/upgrade_assistant/server/lib/es_migration_apis.ts
index 4985cad8bd750..aeee9a925ed70 100644
--- a/x-pack/plugins/upgrade_assistant/server/lib/es_migration_apis.ts
+++ b/x-pack/plugins/upgrade_assistant/server/lib/es_migration_apis.ts
@@ -12,7 +12,6 @@ import {
UpgradeAssistantStatus,
} from '../../common/types';
-import { getDeprecatedApmIndices } from './apm';
import { isSystemIndex } from './reindexing';
import { esIndicesStateCheck } from './es_indices_state_check';
@@ -20,15 +19,13 @@ import { esIndicesStateCheck } from './es_indices_state_check';
export async function getUpgradeAssistantStatus(
dataClient: IScopedClusterClient,
isCloudEnabled: boolean,
- apmIndices: string[]
): Promise {
- const [{ body: deprecations }, apmIndexDeprecations] = await Promise.all([
+ const [{ body: deprecations }] = await Promise.all([
dataClient.asCurrentUser.migration.deprecations(),
- getDeprecatedApmIndices(dataClient, apmIndices),
]);
const cluster = getClusterDeprecations(deprecations, isCloudEnabled);
- const indices = getCombinedIndexInfos(deprecations, apmIndexDeprecations);
+ const indices = getCombinedIndexInfos(deprecations);
const indexNames = indices.map(({ index }) => index!);
@@ -55,14 +52,10 @@ export async function getUpgradeAssistantStatus(
// Reformats the index deprecations to an array of deprecation warnings extended with an index field.
const getCombinedIndexInfos = (
deprecations: DeprecationAPIResponse,
- apmIndexDeprecations: EnrichedDeprecationInfo[]
) => {
- const apmIndices = apmIndexDeprecations.reduce((acc, dep) => acc.add(dep.index), new Set());
return (
Object.keys(deprecations.index_settings)
- // prevent APM indices from showing up for general re-indexing
- .filter((indexName) => !apmIndices.has(indexName))
.reduce((indexDeprecations, indexName) => {
return indexDeprecations.concat(
deprecations.index_settings[indexName].map(
@@ -70,7 +63,7 @@ const getCombinedIndexInfos = (
({
...d,
index: indexName,
- reindex: /Index created before/.test(d.message) && !apmIndices.has(indexName),
+ reindex: /Index created before/.test(d.message),
needsDefaultFields: /Number of fields exceeds automatic field expansion limit/.test(
d.message
),
@@ -79,9 +72,8 @@ const getCombinedIndexInfos = (
);
}, [] as EnrichedDeprecationInfo[])
// Filter out warnings for system indices until we know more about what changes are required for the
- // next upgrade in a future minor version. Note, we're still including APM depercations below.
+ // next upgrade in a future minor version.
.filter((deprecation) => !isSystemIndex(deprecation.index!))
- .concat(apmIndexDeprecations)
);
};
diff --git a/x-pack/plugins/upgrade_assistant/server/lib/es_version_precheck.test.ts b/x-pack/plugins/upgrade_assistant/server/lib/es_version_precheck.test.ts
index 25dcd2521525d..f4631f3ba459d 100644
--- a/x-pack/plugins/upgrade_assistant/server/lib/es_version_precheck.test.ts
+++ b/x-pack/plugins/upgrade_assistant/server/lib/es_version_precheck.test.ts
@@ -9,7 +9,8 @@ import { SemVer } from 'semver';
import { IScopedClusterClient, kibanaResponseFactory } from 'src/core/server';
import { coreMock } from 'src/core/server/mocks';
import { licensingMock } from '../../../../plugins/licensing/server/mocks';
-import { MOCK_VERSION_STRING, getMockVersionInfo } from './__fixtures__/version';
+import { mockKibanaVersion } from '../../common/constants';
+import { getMockVersionInfo } from './__fixtures__/version';
import {
esVersionCheck,
@@ -97,7 +98,7 @@ describe('verifyAllMatchKibanaVersion', () => {
describe('EsVersionPrecheck', () => {
beforeEach(() => {
- versionService.setup(MOCK_VERSION_STRING);
+ versionService.setup(mockKibanaVersion);
});
it('returns a 403 when callCluster fails with a 403', async () => {
diff --git a/x-pack/plugins/upgrade_assistant/server/lib/reindexing/index_settings.test.ts b/x-pack/plugins/upgrade_assistant/server/lib/reindexing/index_settings.test.ts
index c86f54b0fdda4..f778981b95054 100644
--- a/x-pack/plugins/upgrade_assistant/server/lib/reindexing/index_settings.test.ts
+++ b/x-pack/plugins/upgrade_assistant/server/lib/reindexing/index_settings.test.ts
@@ -5,9 +5,10 @@
* 2.0.
*/
+import { mockKibanaSemverVersion, mockKibanaVersion } from '../../../common/constants';
import { ReindexWarning } from '../../../common/types';
import { versionService } from '../version';
-import { MOCK_VERSION_STRING, getMockVersionInfo } from '../__fixtures__/version';
+import { getMockVersionInfo } from '../__fixtures__/version';
import {
generateNewIndexName,
@@ -124,7 +125,7 @@ describe('transformFlatSettings', () => {
describe('sourceNameForIndex', () => {
beforeEach(() => {
- versionService.setup(MOCK_VERSION_STRING);
+ versionService.setup(mockKibanaVersion);
});
it('parses internal indices', () => {
@@ -145,7 +146,7 @@ describe('sourceNameForIndex', () => {
describe('generateNewIndexName', () => {
beforeEach(() => {
- versionService.setup(MOCK_VERSION_STRING);
+ versionService.setup(mockKibanaVersion);
});
it('parses internal indices', () => {
@@ -179,21 +180,25 @@ describe('getReindexWarnings', () => {
).toEqual([]);
});
- it('returns customTypeName for non-_doc mapping types', () => {
- expect(
- getReindexWarnings({
- settings: {},
- mappings: { doc: {} },
- })
- ).toEqual([ReindexWarning.customTypeName]);
- });
-
- it('does not return customTypeName for _doc mapping types', () => {
- expect(
- getReindexWarnings({
- settings: {},
- mappings: { _doc: {} },
- })
- ).toEqual([]);
- });
+ if (mockKibanaSemverVersion.major === 7) {
+ describe('customTypeName warning', () => {
+ it('returns customTypeName for non-_doc mapping types', () => {
+ expect(
+ getReindexWarnings({
+ settings: {},
+ mappings: { doc: {} },
+ })
+ ).toEqual([ReindexWarning.customTypeName]);
+ });
+
+ it('does not return customTypeName for _doc mapping types', () => {
+ expect(
+ getReindexWarnings({
+ settings: {},
+ mappings: { _doc: {} },
+ })
+ ).toEqual([]);
+ });
+ });
+ }
});
diff --git a/x-pack/plugins/upgrade_assistant/server/lib/reindexing/index_settings.ts b/x-pack/plugins/upgrade_assistant/server/lib/reindexing/index_settings.ts
index 797f0de4ac95d..d85efb3882643 100644
--- a/x-pack/plugins/upgrade_assistant/server/lib/reindexing/index_settings.ts
+++ b/x-pack/plugins/upgrade_assistant/server/lib/reindexing/index_settings.ts
@@ -7,12 +7,8 @@
import { flow, omit } from 'lodash';
import { ReindexWarning } from '../../../common/types';
-import { isLegacyApmIndex } from '../apm';
import { versionService } from '../version';
import { FlatSettings, FlatSettingsWithTypeName } from './types';
-
-export const DEFAULT_TYPE_NAME = '_doc';
-
export interface ParsedIndexName {
cleanIndexName: string;
baseName: string;
@@ -73,31 +69,22 @@ export const generateNewIndexName = (indexName: string): string => {
* @param flatSettings
*/
export const getReindexWarnings = (
- flatSettings: FlatSettingsWithTypeName,
- apmIndexPatterns: string[] = []
+ flatSettings: FlatSettingsWithTypeName | FlatSettings
): ReindexWarning[] => {
- const indexName = flatSettings.settings['index.provided_name'];
- const typeName = Object.getOwnPropertyNames(flatSettings.mappings)[0];
- const apmReindexWarning = isLegacyApmIndex(
- indexName,
- apmIndexPatterns,
- flatSettings.mappings[typeName]
- );
- const typeNameWarning = usesCustomTypeName(flatSettings);
-
- const warnings = [
- [ReindexWarning.apmReindex, apmReindexWarning],
- [ReindexWarning.customTypeName, typeNameWarning],
- ] as Array<[ReindexWarning, boolean]>;
+ const warnings = [] as Array<[ReindexWarning, boolean]>;
- return warnings.filter(([_, applies]) => applies).map(([warning, _]) => warning);
-};
+ if (versionService.getMajorVersion() === 7) {
+ const DEFAULT_TYPE_NAME = '_doc';
+ // In 7+ it's not possible to have more than one type anyways, so always grab the first
+ // (and only) key.
+ const typeName = Object.getOwnPropertyNames(flatSettings.mappings)[0];
-const usesCustomTypeName = (flatSettings: FlatSettingsWithTypeName) => {
- // In 7+ it's not possible to have more than one type anyways, so always grab the first
- // (and only) key.
- const typeName = Object.getOwnPropertyNames(flatSettings.mappings)[0];
- return typeName && typeName !== DEFAULT_TYPE_NAME;
+ const typeNameWarning = Boolean(typeName && typeName !== DEFAULT_TYPE_NAME);
+
+ warnings.push([ReindexWarning.customTypeName, typeNameWarning]);
+ }
+
+ return warnings.filter(([_, applies]) => applies).map(([warning, _]) => warning);
};
const removeUnsettableSettings = (settings: FlatSettings['settings']) =>
diff --git a/x-pack/plugins/upgrade_assistant/server/lib/reindexing/reindex_actions.test.ts b/x-pack/plugins/upgrade_assistant/server/lib/reindexing/reindex_actions.test.ts
index 59c83a05aa551..592c2d15b9c0c 100644
--- a/x-pack/plugins/upgrade_assistant/server/lib/reindexing/reindex_actions.test.ts
+++ b/x-pack/plugins/upgrade_assistant/server/lib/reindexing/reindex_actions.test.ts
@@ -19,9 +19,10 @@ import {
ReindexStatus,
ReindexStep,
} from '../../../common/types';
+import { mockKibanaVersion } from '../../../common/constants';
import { versionService } from '../version';
import { LOCK_WINDOW, ReindexActions, reindexActionsFactory } from './reindex_actions';
-import { MOCK_VERSION_STRING, getMockVersionInfo } from '../__fixtures__/version';
+import { getMockVersionInfo } from '../__fixtures__/version';
const { currentMajor, prevMajor } = getMockVersionInfo();
@@ -53,7 +54,7 @@ describe('ReindexActions', () => {
describe('createReindexOp', () => {
beforeEach(() => {
- versionService.setup(MOCK_VERSION_STRING);
+ versionService.setup(mockKibanaVersion);
client.create.mockResolvedValue();
});
diff --git a/x-pack/plugins/upgrade_assistant/server/lib/reindexing/reindex_actions.ts b/x-pack/plugins/upgrade_assistant/server/lib/reindexing/reindex_actions.ts
index c4b15b1453754..798d5f7d44747 100644
--- a/x-pack/plugins/upgrade_assistant/server/lib/reindexing/reindex_actions.ts
+++ b/x-pack/plugins/upgrade_assistant/server/lib/reindexing/reindex_actions.ts
@@ -21,6 +21,7 @@ import {
ReindexStatus,
ReindexStep,
} from '../../../common/types';
+import { versionService } from '../version';
import { generateNewIndexName } from './index_settings';
import { FlatSettings, FlatSettingsWithTypeName } from './types';
@@ -85,7 +86,7 @@ export interface ReindexActions {
* Retrieve index settings (in flat, dot-notation style) and mappings.
* @param indexName
*/
- getFlatSettings(indexName: string): Promise;
+ getFlatSettings(indexName: string): Promise;
/**
* Retrieve index settings (in flat, dot-notation style) and mappings with the type name included.
@@ -243,18 +244,33 @@ export const reindexActionsFactory = (
},
async getFlatSettings(indexName: string) {
- const { body: flatSettings } = await esClient.indices.get<{
- [indexName: string]: FlatSettings;
- }>({
- index: indexName,
- flat_settings: true,
- });
+ let flatSettings;
+
+ if (versionService.getMajorVersion() === 7) {
+ // On 7.x, we need to get index settings with mapping type
+ flatSettings = await esClient.indices.get<{
+ [indexName: string]: FlatSettingsWithTypeName;
+ }>({
+ index: indexName,
+ flat_settings: true,
+ // This @ts-ignore is needed on master since the flag is deprecated on >7.x
+ // @ts-ignore
+ include_type_name: true,
+ });
+ } else {
+ flatSettings = await esClient.indices.get<{
+ [indexName: string]: FlatSettings;
+ }>({
+ index: indexName,
+ flat_settings: true,
+ });
+ }
- if (!flatSettings[indexName]) {
+ if (!flatSettings.body[indexName]) {
return null;
}
- return flatSettings[indexName];
+ return flatSettings.body[indexName];
},
async getFlatSettingsWithTypeName(indexName: string) {
diff --git a/x-pack/plugins/upgrade_assistant/server/lib/reindexing/reindex_service.test.ts b/x-pack/plugins/upgrade_assistant/server/lib/reindexing/reindex_service.test.ts
index 90ff699d79a72..06e6ad9d646e8 100644
--- a/x-pack/plugins/upgrade_assistant/server/lib/reindexing/reindex_service.test.ts
+++ b/x-pack/plugins/upgrade_assistant/server/lib/reindexing/reindex_service.test.ts
@@ -20,12 +20,11 @@ import {
ReindexStatus,
ReindexStep,
} from '../../../common/types';
+import { mockKibanaVersion } from '../../../common/constants';
import { licensingMock } from '../../../../licensing/server/mocks';
import { LicensingPluginSetup } from '../../../../licensing/server';
-import { apmReindexScript } from '../apm';
-import apmMappings from '../apm/mapping.json';
-import { MOCK_VERSION_STRING, getMockVersionInfo } from '../__fixtures__/version';
+import { getMockVersionInfo } from '../__fixtures__/version';
import { esIndicesStateCheck } from '../es_indices_state_check';
import { versionService } from '../version';
@@ -89,10 +88,9 @@ describe('reindexService', () => {
actions,
log,
licensingPluginSetup,
- ['apm-*']
);
- versionService.setup(MOCK_VERSION_STRING);
+ versionService.setup(mockKibanaVersion);
});
describe('hasRequiredPrivileges', () => {
@@ -846,46 +844,6 @@ describe('reindexService', () => {
});
});
- it('used APM mapping for legacy APM index', async () => {
- const indexName = 'apm-1';
- const newIndexName = 'apm-1-reindexed';
-
- actions.getFlatSettings.mockResolvedValueOnce({
- settings: {
- 'index.number_of_replicas': 5,
- },
- mappings: {
- _meta: {
- version: '6.7.0',
- },
- },
- });
-
- clusterClient.asCurrentUser.indices.create.mockResolvedValueOnce(
- asApiResponse({ acknowledged: true })
- );
-
- await service.processNextStep({
- id: '1',
- attributes: {
- ...defaultAttributes,
- indexName,
- newIndexName,
- lastCompletedStep: ReindexStep.readonly,
- },
- } as ReindexSavedObject);
-
- expect(clusterClient.asCurrentUser.indices.create).toHaveBeenCalledWith({
- index: newIndexName,
- body: {
- mappings: apmMappings,
- settings: {
- 'index.number_of_replicas': 5,
- },
- },
- });
- });
-
it('fails if create index is not acknowledged', async () => {
clusterClient.asCurrentUser.indices.get.mockResolvedValueOnce(
asApiResponse({ myIndex: settingsMappings })
@@ -958,44 +916,6 @@ describe('reindexService', () => {
});
});
- it('uses APM script for legacy APM index', async () => {
- const indexName = 'apm-1';
- const newIndexName = 'apm-1-reindexed';
-
- clusterClient.asCurrentUser.reindex.mockResolvedValueOnce(asApiResponse({ task: 'xyz' }));
-
- actions.getFlatSettings.mockResolvedValueOnce({
- settings: {},
- mappings: {
- _meta: {
- version: '6.7.0',
- },
- },
- });
-
- await service.processNextStep({
- id: '1',
- attributes: {
- ...defaultAttributes,
- indexName,
- newIndexName,
- lastCompletedStep: ReindexStep.newIndexCreated,
- },
- } as ReindexSavedObject);
- expect(clusterClient.asCurrentUser.reindex).toHaveBeenLastCalledWith({
- refresh: true,
- wait_for_completion: false,
- body: {
- source: { index: indexName },
- dest: { index: newIndexName },
- script: {
- lang: 'painless',
- source: apmReindexScript,
- },
- },
- });
- });
-
it('fails if starting reindex fails', async () => {
clusterClient.asCurrentUser.reindex.mockRejectedValueOnce(new Error('blah!'));
const updatedOp = await service.processNextStep(reindexOp);
diff --git a/x-pack/plugins/upgrade_assistant/server/lib/reindexing/reindex_service.ts b/x-pack/plugins/upgrade_assistant/server/lib/reindexing/reindex_service.ts
index 92eab9be21d95..b6c4140bd4169 100644
--- a/x-pack/plugins/upgrade_assistant/server/lib/reindexing/reindex_service.ts
+++ b/x-pack/plugins/upgrade_assistant/server/lib/reindexing/reindex_service.ts
@@ -17,8 +17,7 @@ import {
ReindexStep,
ReindexWarning,
} from '../../../common/types';
-import { apmReindexScript, isLegacyApmIndex } from '../apm';
-import apmMappings from '../apm/mapping.json';
+
import { esIndicesStateCheck } from '../es_indices_state_check';
@@ -137,7 +136,6 @@ export const reindexServiceFactory = (
actions: ReindexActions,
log: Logger,
licensing: LicensingPluginSetup,
- apmIndexPatterns: string[] = []
): ReindexService => {
// ------ Utility functions
@@ -318,13 +316,12 @@ export const reindexServiceFactory = (
}
const { settings, mappings } = transformFlatSettings(flatSettings);
- const legacyApmIndex = isLegacyApmIndex(indexName, apmIndexPatterns, flatSettings.mappings);
const { body: createIndex } = await esClient.indices.create({
index: newIndexName,
body: {
settings,
- mappings: legacyApmIndex ? apmMappings : mappings,
+ mappings,
},
});
@@ -353,28 +350,18 @@ export const reindexServiceFactory = (
await esClient.indices.open({ index: indexName });
}
- const reindexBody = {
- source: { index: indexName },
- dest: { index: reindexOp.attributes.newIndexName },
- } as any;
-
const flatSettings = await actions.getFlatSettings(indexName);
if (!flatSettings) {
throw error.indexNotFound(`Index ${indexName} does not exist.`);
}
- const legacyApmIndex = isLegacyApmIndex(indexName, apmIndexPatterns, flatSettings.mappings);
- if (legacyApmIndex) {
- reindexBody.script = {
- lang: 'painless',
- source: apmReindexScript,
- };
- }
-
const { body: startReindexResponse } = await esClient.reindex({
refresh: true,
wait_for_completion: false,
- body: reindexBody,
+ body: {
+ source: { index: indexName },
+ dest: { index: reindexOp.attributes.newIndexName },
+ },
});
return actions.updateReindexOp(reindexOp, {
@@ -569,7 +556,7 @@ export const reindexServiceFactory = (
if (!flatSettings) {
return null;
} else {
- return getReindexWarnings(flatSettings, apmIndexPatterns);
+ return getReindexWarnings(flatSettings);
}
},
diff --git a/x-pack/plugins/upgrade_assistant/server/lib/reindexing/types.ts b/x-pack/plugins/upgrade_assistant/server/lib/reindexing/types.ts
index f96eeec36963b..c26dbbb1bf4c0 100644
--- a/x-pack/plugins/upgrade_assistant/server/lib/reindexing/types.ts
+++ b/x-pack/plugins/upgrade_assistant/server/lib/reindexing/types.ts
@@ -28,6 +28,10 @@ export interface FlatSettings {
};
}
+<<<<<<< HEAD
+=======
+// Specific to 7.x-8 upgrade
+>>>>>>> fe6bd2ecbb4... [Upgrade Assistant] Align code between branches (#91862)
export interface FlatSettingsWithTypeName {
settings: {
[key: string]: string;
diff --git a/x-pack/plugins/upgrade_assistant/server/lib/reindexing/worker.ts b/x-pack/plugins/upgrade_assistant/server/lib/reindexing/worker.ts
index 1163f36733287..6d55b1e8007f0 100644
--- a/x-pack/plugins/upgrade_assistant/server/lib/reindexing/worker.ts
+++ b/x-pack/plugins/upgrade_assistant/server/lib/reindexing/worker.ts
@@ -53,7 +53,6 @@ export class ReindexWorker {
private clusterClient: IClusterClient,
log: Logger,
private licensing: LicensingPluginSetup,
- private apmIndexPatterns: string[]
) {
this.log = log.get('reindex_worker');
if (ReindexWorker.workerSingleton) {
@@ -67,7 +66,6 @@ export class ReindexWorker {
reindexActionsFactory(this.client, callAsInternalUser),
log,
this.licensing,
- apmIndexPatterns
);
ReindexWorker.workerSingleton = this;
@@ -157,7 +155,6 @@ export class ReindexWorker {
actions,
this.log,
this.licensing,
- this.apmIndexPatterns
);
};
@@ -239,7 +236,6 @@ export class ReindexWorker {
actions,
this.log,
this.licensing,
- this.apmIndexPatterns
);
reindexOp = await swallowExceptions(service.processNextStep, this.log)(reindexOp);
diff --git a/x-pack/plugins/upgrade_assistant/server/plugin.ts b/x-pack/plugins/upgrade_assistant/server/plugin.ts
index b6b9b5390b004..1c7483f8ebc35 100644
--- a/x-pack/plugins/upgrade_assistant/server/plugin.ts
+++ b/x-pack/plugins/upgrade_assistant/server/plugin.ts
@@ -5,7 +5,6 @@
* 2.0.
*/
-import { first } from 'rxjs/operators';
import { UsageCollectionSetup } from 'src/plugins/usage_collection/server';
import {
@@ -21,9 +20,6 @@ import {
import { CloudSetup } from '../../cloud/server';
import { PluginSetupContract as FeaturesPluginSetup } from '../../features/server';
import { LicensingPluginSetup } from '../../licensing/server';
-import { APMOSSPluginSetup } from '../../../../src/plugins/apm_oss/server';
-
-import { extractIndexPatterns } from './lib/apm/extract_index_patterns';
import { CredentialStore, credentialStoreFactory } from './lib/reindexing/credential_store';
import { ReindexWorker } from './lib/reindexing';
@@ -41,7 +37,6 @@ import { RouteDependencies } from './types';
interface PluginsSetup {
usageCollection: UsageCollectionSetup;
licensing: LicensingPluginSetup;
- apmOss: APMOSSPluginSetup;
features: FeaturesPluginSetup;
cloud?: CloudSetup;
}
@@ -53,7 +48,6 @@ export class UpgradeAssistantServerPlugin implements Plugin {
// Properties set at setup
private licensing?: LicensingPluginSetup;
- private apmOSS?: APMOSSPluginSetup;
// Properties set at start
private savedObjectsServiceStart?: SavedObjectsServiceStart;
@@ -74,10 +68,9 @@ export class UpgradeAssistantServerPlugin implements Plugin {
setup(
{ http, getStartServices, capabilities, savedObjects }: CoreSetup,
- { usageCollection, cloud, features, licensing, apmOss: apmOSS }: PluginsSetup
+ { usageCollection, cloud, features, licensing }: PluginsSetup
) {
this.licensing = licensing;
- this.apmOSS = apmOSS;
savedObjects.registerType(reindexOperationSavedObjectType);
savedObjects.registerType(telemetrySavedObjectType);
@@ -100,7 +93,6 @@ export class UpgradeAssistantServerPlugin implements Plugin {
const dependencies: RouteDependencies = {
cloud,
router,
- apmOSS,
credentialStore: this.credentialStore,
log: this.logger,
getSavedObjectsService: () => {
@@ -143,10 +135,6 @@ export class UpgradeAssistantServerPlugin implements Plugin {
// process jobs without the browser staying on the page, but will require that jobs go into
// a paused state if no Kibana nodes have the required credentials.
- const apmIndexPatterns = extractIndexPatterns(
- await this.apmOSS!.config$.pipe(first()).toPromise()
- );
-
this.worker = createReindexWorker({
credentialStore: this.credentialStore,
licensing: this.licensing!,
@@ -155,7 +143,6 @@ export class UpgradeAssistantServerPlugin implements Plugin {
savedObjects: new SavedObjectsClient(
this.savedObjectsServiceStart.createInternalRepository()
),
- apmIndexPatterns,
});
this.worker!.start();
diff --git a/x-pack/plugins/upgrade_assistant/server/routes/cluster_checkup.test.ts b/x-pack/plugins/upgrade_assistant/server/routes/cluster_checkup.test.ts
index 6b831a8e591f7..a5da4741b10eb 100644
--- a/x-pack/plugins/upgrade_assistant/server/routes/cluster_checkup.test.ts
+++ b/x-pack/plugins/upgrade_assistant/server/routes/cluster_checkup.test.ts
@@ -6,7 +6,6 @@
*/
import { kibanaResponseFactory } from 'src/core/server';
-import { apmOSSPluginSetupMock } from '../../../../../src/plugins/apm_oss/server/mocks';
import { createMockRouter, MockRouter, routeHandlerContextMock } from './__mocks__/routes.mock';
import { createRequestMock } from './__mocks__/request.mock';
@@ -36,7 +35,6 @@ describe('cluster checkup API', () => {
cloud: {
isCloudEnabled: true,
},
- apmOSS: apmOSSPluginSetupMock.create({ indexPattern: 'apm-*' }),
router: mockRouter,
};
registerClusterCheckupRoutes(routeDependencies);
@@ -64,25 +62,6 @@ describe('cluster checkup API', () => {
});
});
- describe('with APM enabled', () => {
- it('is provided to getUpgradeAssistantStatus', async () => {
- const spy = jest.spyOn(MigrationApis, 'getUpgradeAssistantStatus');
-
- MigrationApis.getUpgradeAssistantStatus.mockResolvedValue({
- cluster: [],
- indices: [],
- nodes: [],
- });
-
- await routeDependencies.router.getHandler({
- method: 'get',
- pathPattern: '/api/upgrade_assistant/status',
- })(routeHandlerContextMock, createRequestMock(), kibanaResponseFactory);
-
- expect(spy.mock.calls[0][2]).toEqual(['apm-*']);
- });
- });
-
describe('GET /api/upgrade_assistant/reindex/{indexName}.json', () => {
it('returns state', async () => {
MigrationApis.getUpgradeAssistantStatus.mockResolvedValue({
diff --git a/x-pack/plugins/upgrade_assistant/server/routes/cluster_checkup.ts b/x-pack/plugins/upgrade_assistant/server/routes/cluster_checkup.ts
index 923fc547071b8..fc3ad98401594 100644
--- a/x-pack/plugins/upgrade_assistant/server/routes/cluster_checkup.ts
+++ b/x-pack/plugins/upgrade_assistant/server/routes/cluster_checkup.ts
@@ -5,10 +5,8 @@
* 2.0.
*/
-import { first } from 'rxjs/operators';
import { getUpgradeAssistantStatus } from '../lib/es_migration_apis';
import { versionCheckHandlerWrapper } from '../lib/es_version_precheck';
-import { extractIndexPatterns } from '../lib/apm/extract_index_patterns';
import { RouteDependencies } from '../types';
import { reindexActionsFactory } from '../lib/reindexing/reindex_actions';
import { reindexServiceFactory } from '../lib/reindexing';
@@ -16,7 +14,6 @@ import { reindexServiceFactory } from '../lib/reindexing';
export function registerClusterCheckupRoutes({
cloud,
router,
- apmOSS,
licensing,
log,
}: RouteDependencies) {
@@ -39,10 +36,7 @@ export function registerClusterCheckupRoutes({
response
) => {
try {
- const apmConfig = await apmOSS.config$.pipe(first()).toPromise();
- const indexPatterns = extractIndexPatterns(apmConfig);
-
- const status = await getUpgradeAssistantStatus(client, isCloudEnabled, indexPatterns);
+ const status = await getUpgradeAssistantStatus(client, isCloudEnabled);
const asCurrentUser = client.asCurrentUser;
const reindexActions = reindexActionsFactory(savedObjectsClient, asCurrentUser);
diff --git a/x-pack/plugins/upgrade_assistant/server/routes/reindex_indices/reindex_indices.test.ts b/x-pack/plugins/upgrade_assistant/server/routes/reindex_indices/reindex_indices.test.ts
index b74a52db7da16..21dded346bbd3 100644
--- a/x-pack/plugins/upgrade_assistant/server/routes/reindex_indices/reindex_indices.test.ts
+++ b/x-pack/plugins/upgrade_assistant/server/routes/reindex_indices/reindex_indices.test.ts
@@ -7,7 +7,6 @@
import { kibanaResponseFactory } from 'src/core/server';
import { licensingMock } from '../../../../licensing/server/mocks';
-import { apmOSSPluginSetupMock } from '../../../../../../src/plugins/apm_oss/server/mocks';
import { createMockRouter, MockRouter, routeHandlerContextMock } from '../__mocks__/routes.mock';
import { createRequestMock } from '../__mocks__/request.mock';
@@ -61,7 +60,6 @@ describe('reindex API', () => {
routeDependencies = {
credentialStore,
router: mockRouter,
- apmOSS: apmOSSPluginSetupMock.create(),
licensing: licensingMock.createSetup(),
};
registerReindexIndicesRoutes(routeDependencies, () => worker);
@@ -91,7 +89,9 @@ describe('reindex API', () => {
mockReindexService.findReindexOperation.mockResolvedValueOnce({
attributes: { indexName: 'wowIndex', status: ReindexStatus.inProgress },
});
- mockReindexService.detectReindexWarnings.mockResolvedValueOnce([ReindexWarning.apmReindex]);
+ mockReindexService.detectReindexWarnings.mockResolvedValueOnce([
+ ReindexWarning.customTypeName,
+ ]);
const resp = await routeDependencies.router.getHandler({
method: 'get',
diff --git a/x-pack/plugins/upgrade_assistant/server/routes/reindex_indices/reindex_indices.ts b/x-pack/plugins/upgrade_assistant/server/routes/reindex_indices/reindex_indices.ts
index bfc794e6493f8..28730012b51b6 100644
--- a/x-pack/plugins/upgrade_assistant/server/routes/reindex_indices/reindex_indices.ts
+++ b/x-pack/plugins/upgrade_assistant/server/routes/reindex_indices/reindex_indices.ts
@@ -45,7 +45,6 @@ interface CreateReindexWorker {
credentialStore: CredentialStore;
savedObjects: SavedObjectsClient;
licensing: LicensingPluginSetup;
- apmIndexPatterns: string[];
}
export function createReindexWorker({
@@ -54,7 +53,6 @@ export function createReindexWorker({
credentialStore,
savedObjects,
licensing,
- apmIndexPatterns,
}: CreateReindexWorker) {
const esClient = elasticsearchService.client;
return new ReindexWorker(
@@ -63,7 +61,6 @@ export function createReindexWorker({
esClient,
logger,
licensing,
- apmIndexPatterns
);
}
diff --git a/x-pack/plugins/upgrade_assistant/server/types.ts b/x-pack/plugins/upgrade_assistant/server/types.ts
index ad450a3fdaf1c..80c60e3f310bc 100644
--- a/x-pack/plugins/upgrade_assistant/server/types.ts
+++ b/x-pack/plugins/upgrade_assistant/server/types.ts
@@ -9,11 +9,9 @@ import { IRouter, Logger, SavedObjectsServiceStart } from 'src/core/server';
import { CloudSetup } from '../../cloud/server';
import { CredentialStore } from './lib/reindexing/credential_store';
import { LicensingPluginSetup } from '../../licensing/server';
-import { APMOSSPluginSetup } from '../../../../src/plugins/apm_oss/server';
export interface RouteDependencies {
router: IRouter;
- apmOSS: APMOSSPluginSetup;
credentialStore: CredentialStore;
log: Logger;
getSavedObjectsService: () => SavedObjectsServiceStart;
diff --git a/x-pack/plugins/upgrade_assistant/tsconfig.json b/x-pack/plugins/upgrade_assistant/tsconfig.json
index 2f6bdd371ad0d..220ae4d0f0160 100644
--- a/x-pack/plugins/upgrade_assistant/tsconfig.json
+++ b/x-pack/plugins/upgrade_assistant/tsconfig.json
@@ -19,7 +19,6 @@
{ "path": "../../../src/core/tsconfig.json" },
{ "path": "../../../src/plugins/management/tsconfig.json" },
{ "path": "../../../src/plugins/usage_collection/tsconfig.json" },
- { "path": "../../../src/plugins/apm_oss/tsconfig.json"},
{ "path": "../cloud/tsconfig.json" },
{ "path": "../features/tsconfig.json" },
{ "path": "../licensing/tsconfig.json" },
From 6429e2830dbba28c097441cc71fc7aa81eae6de1 Mon Sep 17 00:00:00 2001
From: Alison Goryachev
Date: Wed, 24 Feb 2021 20:32:17 -0500
Subject: [PATCH 2/2] fix backport
---
.../translations/translations/ja-JP.json | 6 -
.../translations/translations/zh-CN.json | 6 -
.../checklist_step.test.tsx.snap | 24 ----
.../__snapshots__/warning_step.test.tsx.snap | 36 ++++++
.../reindex/flyout/checklist_step.tsx | 5 +-
.../es_migration_apis.test.ts.snap | 38 +++++-
.../server/lib/es_migration_apis.test.ts | 10 +-
.../server/lib/es_migration_apis.ts | 49 +++-----
.../server/lib/query_default_field.test.ts | 116 ------------------
.../server/lib/query_default_field.ts | 74 -----------
.../server/lib/reindexing/error.ts | 2 -
.../server/lib/reindexing/error_symbols.ts | 1 -
.../server/lib/reindexing/index.ts | 2 +-
.../server/lib/reindexing/reindex_actions.ts | 32 ++---
.../lib/reindexing/reindex_service.test.ts | 15 +--
.../server/lib/reindexing/reindex_service.ts | 16 +--
.../server/lib/reindexing/types.ts | 3 -
.../server/lib/reindexing/worker.ts | 18 +--
.../upgrade_assistant/server/plugin.ts | 6 +-
.../server/routes/cluster_checkup.ts | 7 +-
.../routes/query_default_field.test.mocks.ts | 12 --
.../server/routes/query_default_field.test.ts | 86 -------------
.../server/routes/query_default_field.ts | 69 -----------
.../routes/reindex_indices/reindex_indices.ts | 12 +-
.../upgrade_assistant/index.js | 1 -
.../upgrade_assistant/query_default_field.js | 48 --------
26 files changed, 117 insertions(+), 577 deletions(-)
delete mode 100644 x-pack/plugins/upgrade_assistant/server/lib/query_default_field.test.ts
delete mode 100644 x-pack/plugins/upgrade_assistant/server/lib/query_default_field.ts
delete mode 100644 x-pack/plugins/upgrade_assistant/server/routes/query_default_field.test.mocks.ts
delete mode 100644 x-pack/plugins/upgrade_assistant/server/routes/query_default_field.test.ts
delete mode 100644 x-pack/plugins/upgrade_assistant/server/routes/query_default_field.ts
delete mode 100644 x-pack/test/upgrade_assistant_integration/upgrade_assistant/query_default_field.js
diff --git a/x-pack/plugins/translations/translations/ja-JP.json b/x-pack/plugins/translations/translations/ja-JP.json
index 50ba18f93b687..f0a6c76dbb454 100644
--- a/x-pack/plugins/translations/translations/ja-JP.json
+++ b/x-pack/plugins/translations/translations/ja-JP.json
@@ -21502,10 +21502,6 @@
"xpack.upgradeAssistant.checkupTab.deprecations.indexTable.indexColumnLabel": "インデックス",
"xpack.upgradeAssistant.checkupTab.deprecations.warningActionTooltip": "アップグレード前にこの問題を解決することをお勧めしますが、必須ではありません。",
"xpack.upgradeAssistant.checkupTab.deprecations.warningLabel": "警告",
- "xpack.upgradeAssistant.checkupTab.fixMetricbeatIndexButton.failedLabel": "失敗",
- "xpack.upgradeAssistant.checkupTab.fixMetricbeatIndexButton.fixedLabel": "修正済み",
- "xpack.upgradeAssistant.checkupTab.fixMetricbeatIndexButton.fixingLabel": "修正中…",
- "xpack.upgradeAssistant.checkupTab.fixMetricbeatIndexButton.reindexLabel": "修正",
"xpack.upgradeAssistant.checkupTab.indexLabel": "インデックス",
"xpack.upgradeAssistant.checkupTab.indicesBadgeLabel": "{numIndices, plural, other {インデックス}}",
"xpack.upgradeAssistant.checkupTab.indicesTabLabel": "インデックス",
@@ -21515,8 +21511,6 @@
"xpack.upgradeAssistant.checkupTab.noIssues.noIssuesLabel": "{strongCheckupLabel} の問題がありません。",
"xpack.upgradeAssistant.checkupTab.noIssues.noIssuesTitle": "完璧です!",
"xpack.upgradeAssistant.checkupTab.numDeprecationsShownLabel": "{total} 件中 {numShown} 件を表示中",
- "xpack.upgradeAssistant.checkupTab.reindexing.flyout.checklistStep.apmIndexPatternCallout.apmSetupLinkLabel": "APMのセットアップ手順",
- "xpack.upgradeAssistant.checkupTab.reindexing.flyout.checklistStep.apmIndexPatternCallout.calloutTitle": "APMインデックスの再インデックス後、{apmSetupLink}に戻ってKibanaオブジェクトを再度読み込んでください。これは1度だけ必要な作業です。",
"xpack.upgradeAssistant.checkupTab.reindexing.flyout.checklistStep.cancelButtonLabel": "キャンセル",
"xpack.upgradeAssistant.checkupTab.reindexing.flyout.checklistStep.closeButtonLabel": "閉じる",
"xpack.upgradeAssistant.checkupTab.reindexing.flyout.checklistStep.continueButtonLabel": "再インデックスを続ける",
diff --git a/x-pack/plugins/translations/translations/zh-CN.json b/x-pack/plugins/translations/translations/zh-CN.json
index 179e60b68cbeb..be02e8f51b23c 100644
--- a/x-pack/plugins/translations/translations/zh-CN.json
+++ b/x-pack/plugins/translations/translations/zh-CN.json
@@ -21552,10 +21552,6 @@
"xpack.upgradeAssistant.checkupTab.deprecations.indexTable.indexColumnLabel": "索引",
"xpack.upgradeAssistant.checkupTab.deprecations.warningActionTooltip": "建议在升级之前先解决此问题,但这不是必需的。",
"xpack.upgradeAssistant.checkupTab.deprecations.warningLabel": "警告",
- "xpack.upgradeAssistant.checkupTab.fixMetricbeatIndexButton.failedLabel": "失败",
- "xpack.upgradeAssistant.checkupTab.fixMetricbeatIndexButton.fixedLabel": "已修复",
- "xpack.upgradeAssistant.checkupTab.fixMetricbeatIndexButton.fixingLabel": "正在修复……",
- "xpack.upgradeAssistant.checkupTab.fixMetricbeatIndexButton.reindexLabel": "修复",
"xpack.upgradeAssistant.checkupTab.indexLabel": "索引",
"xpack.upgradeAssistant.checkupTab.indicesBadgeLabel": "{numIndices, plural, other { 个索引}}",
"xpack.upgradeAssistant.checkupTab.indicesTabLabel": "索引",
@@ -21565,8 +21561,6 @@
"xpack.upgradeAssistant.checkupTab.noIssues.noIssuesLabel": "您没有 {strongCheckupLabel} 问题。",
"xpack.upgradeAssistant.checkupTab.noIssues.noIssuesTitle": "全部清除!",
"xpack.upgradeAssistant.checkupTab.numDeprecationsShownLabel": "显示 {numShown} 个,共 {total} 个",
- "xpack.upgradeAssistant.checkupTab.reindexing.flyout.checklistStep.apmIndexPatternCallout.apmSetupLinkLabel": "APM 设置说明",
- "xpack.upgradeAssistant.checkupTab.reindexing.flyout.checklistStep.apmIndexPatternCallout.calloutTitle": "重新索引 APM 索引后,返回 {apmSetupLink} 以重新加载 Kibana 对象。您只需执行一次此操作。",
"xpack.upgradeAssistant.checkupTab.reindexing.flyout.checklistStep.cancelButtonLabel": "取消",
"xpack.upgradeAssistant.checkupTab.reindexing.flyout.checklistStep.closeButtonLabel": "关闭",
"xpack.upgradeAssistant.checkupTab.reindexing.flyout.checklistStep.continueButtonLabel": "继续重新索引",
diff --git a/x-pack/plugins/upgrade_assistant/public/application/components/tabs/checkup/deprecations/reindex/flyout/__snapshots__/checklist_step.test.tsx.snap b/x-pack/plugins/upgrade_assistant/public/application/components/tabs/checkup/deprecations/reindex/flyout/__snapshots__/checklist_step.test.tsx.snap
index 3e40d15906def..3ab877c573ef7 100644
--- a/x-pack/plugins/upgrade_assistant/public/application/components/tabs/checkup/deprecations/reindex/flyout/__snapshots__/checklist_step.test.tsx.snap
+++ b/x-pack/plugins/upgrade_assistant/public/application/components/tabs/checkup/deprecations/reindex/flyout/__snapshots__/checklist_step.test.tsx.snap
@@ -57,30 +57,6 @@ exports[`ChecklistFlyout renders 1`] = `
}
}
/>
-
-
-
- ,
- }
- }
- />
- }
- />
+
+ _doc
+ ,
+ }
+ }
+ />
+ }
+ documentationUrl="https://www.elastic.co/guide/en/elasticsearch/reference/current/removal-of-types.html"
+ label={
+
+ _doc
+ ,
+ }
+ }
+ />
+ }
+ onChange={[Function]}
+ warning={0}
+ />
void;
http: HttpSetup;
}> = ({ closeFlyout, reindexState, startReindex, cancelReindex, http, renderGlobalCallouts }) => {
- const { loadingState, status, hasRequiredPrivileges, reindexWarnings } = reindexState;
+ const { loadingState, status, hasRequiredPrivileges } = reindexState;
const loading = loadingState === LoadingState.Loading || status === ReindexStatus.inProgress;
return (
diff --git a/x-pack/plugins/upgrade_assistant/server/lib/__snapshots__/es_migration_apis.test.ts.snap b/x-pack/plugins/upgrade_assistant/server/lib/__snapshots__/es_migration_apis.test.ts.snap
index 7491fb38b849f..244fc96acd194 100644
--- a/x-pack/plugins/upgrade_assistant/server/lib/__snapshots__/es_migration_apis.test.ts.snap
+++ b/x-pack/plugins/upgrade_assistant/server/lib/__snapshots__/es_migration_apis.test.ts.snap
@@ -29,13 +29,48 @@ Object {
},
],
"indices": Array [
+ Object {
+ "blockerForReindexing": undefined,
+ "details": "[[type: doc, field: spins], [type: doc, field: mlockall], [type: doc, field: node_master], [type: doc, field: primary]]",
+ "index": ".monitoring-es-6-2018.11.07",
+ "level": "warning",
+ "message": "Coercion of boolean fields",
+ "reindex": false,
+ "url": "https://www.elastic.co/guide/en/elasticsearch/reference/6.0/breaking_60_mappings_changes.html#_coercion_of_boolean_fields",
+ },
Object {
"blockerForReindexing": undefined,
"details": "[[type: tweet, field: liked]]",
"index": "twitter",
"level": "warning",
"message": "Coercion of boolean fields",
- "needsDefaultFields": false,
+ "reindex": false,
+ "url": "https://www.elastic.co/guide/en/elasticsearch/reference/6.0/breaking_60_mappings_changes.html#_coercion_of_boolean_fields",
+ },
+ Object {
+ "blockerForReindexing": undefined,
+ "details": "[[type: index-pattern, field: notExpandable], [type: config, field: xPackMonitoring:allowReport], [type: config, field: xPackMonitoring:showBanner], [type: dashboard, field: pause], [type: dashboard, field: timeRestore]]",
+ "index": ".kibana",
+ "level": "warning",
+ "message": "Coercion of boolean fields",
+ "reindex": false,
+ "url": "https://www.elastic.co/guide/en/elasticsearch/reference/6.0/breaking_60_mappings_changes.html#_coercion_of_boolean_fields",
+ },
+ Object {
+ "blockerForReindexing": undefined,
+ "details": "[[type: doc, field: notify], [type: doc, field: created], [type: doc, field: attach_payload], [type: doc, field: met]]",
+ "index": ".watcher-history-6-2018.11.07",
+ "level": "warning",
+ "message": "Coercion of boolean fields",
+ "reindex": false,
+ "url": "https://www.elastic.co/guide/en/elasticsearch/reference/6.0/breaking_60_mappings_changes.html#_coercion_of_boolean_fields",
+ },
+ Object {
+ "blockerForReindexing": undefined,
+ "details": "[[type: doc, field: snapshot]]",
+ "index": ".monitoring-kibana-6-2018.11.07",
+ "level": "warning",
+ "message": "Coercion of boolean fields",
"reindex": false,
"url": "https://www.elastic.co/guide/en/elasticsearch/reference/6.0/breaking_60_mappings_changes.html#_coercion_of_boolean_fields",
},
@@ -45,7 +80,6 @@ Object {
"index": "twitter2",
"level": "warning",
"message": "Coercion of boolean fields",
- "needsDefaultFields": false,
"reindex": false,
"url": "https://www.elastic.co/guide/en/elasticsearch/reference/6.0/breaking_60_mappings_changes.html#_coercion_of_boolean_fields",
},
diff --git a/x-pack/plugins/upgrade_assistant/server/lib/es_migration_apis.test.ts b/x-pack/plugins/upgrade_assistant/server/lib/es_migration_apis.test.ts
index c14ff5b842fd9..9ab8d0aa7cffb 100644
--- a/x-pack/plugins/upgrade_assistant/server/lib/es_migration_apis.test.ts
+++ b/x-pack/plugins/upgrade_assistant/server/lib/es_migration_apis.test.ts
@@ -37,12 +37,12 @@ describe('getUpgradeAssistantStatus', () => {
esClient.asCurrentUser.indices.resolveIndex.mockResolvedValue(asApiResponse(resolvedIndices));
it('calls /_migration/deprecations', async () => {
- await getUpgradeAssistantStatus(esClient, false, []);
+ await getUpgradeAssistantStatus(esClient, false);
expect(esClient.asCurrentUser.migration.deprecations).toHaveBeenCalled();
});
it('returns the correct shape of data', async () => {
- const resp = await getUpgradeAssistantStatus(esClient, false, []);
+ const resp = await getUpgradeAssistantStatus(esClient, false);
expect(resp).toMatchSnapshot();
});
@@ -56,7 +56,7 @@ describe('getUpgradeAssistantStatus', () => {
})
);
- await expect(getUpgradeAssistantStatus(esClient, false, [])).resolves.toHaveProperty(
+ await expect(getUpgradeAssistantStatus(esClient, false)).resolves.toHaveProperty(
'readyForUpgrade',
false
);
@@ -72,7 +72,7 @@ describe('getUpgradeAssistantStatus', () => {
})
);
- await expect(getUpgradeAssistantStatus(esClient, false, [])).resolves.toHaveProperty(
+ await expect(getUpgradeAssistantStatus(esClient, false)).resolves.toHaveProperty(
'readyForUpgrade',
true
);
@@ -94,7 +94,7 @@ describe('getUpgradeAssistantStatus', () => {
})
);
- const result = await getUpgradeAssistantStatus(esClient, true, []);
+ const result = await getUpgradeAssistantStatus(esClient, true);
expect(result).toHaveProperty('readyForUpgrade', true);
expect(result).toHaveProperty('cluster', []);
diff --git a/x-pack/plugins/upgrade_assistant/server/lib/es_migration_apis.ts b/x-pack/plugins/upgrade_assistant/server/lib/es_migration_apis.ts
index aeee9a925ed70..6e357fd755c82 100644
--- a/x-pack/plugins/upgrade_assistant/server/lib/es_migration_apis.ts
+++ b/x-pack/plugins/upgrade_assistant/server/lib/es_migration_apis.ts
@@ -12,17 +12,15 @@ import {
UpgradeAssistantStatus,
} from '../../common/types';
-import { isSystemIndex } from './reindexing';
-
import { esIndicesStateCheck } from './es_indices_state_check';
export async function getUpgradeAssistantStatus(
dataClient: IScopedClusterClient,
- isCloudEnabled: boolean,
+ isCloudEnabled: boolean
): Promise {
- const [{ body: deprecations }] = await Promise.all([
- dataClient.asCurrentUser.migration.deprecations(),
- ]);
+ const {
+ body: deprecations,
+ } = await dataClient.asCurrentUser.migration.deprecations();
const cluster = getClusterDeprecations(deprecations, isCloudEnabled);
const indices = getCombinedIndexInfos(deprecations);
@@ -50,32 +48,19 @@ export async function getUpgradeAssistantStatus(
}
// Reformats the index deprecations to an array of deprecation warnings extended with an index field.
-const getCombinedIndexInfos = (
- deprecations: DeprecationAPIResponse,
-) => {
-
- return (
- Object.keys(deprecations.index_settings)
- .reduce((indexDeprecations, indexName) => {
- return indexDeprecations.concat(
- deprecations.index_settings[indexName].map(
- (d) =>
- ({
- ...d,
- index: indexName,
- reindex: /Index created before/.test(d.message),
- needsDefaultFields: /Number of fields exceeds automatic field expansion limit/.test(
- d.message
- ),
- } as EnrichedDeprecationInfo)
- )
- );
- }, [] as EnrichedDeprecationInfo[])
- // Filter out warnings for system indices until we know more about what changes are required for the
- // next upgrade in a future minor version.
- .filter((deprecation) => !isSystemIndex(deprecation.index!))
- );
-};
+const getCombinedIndexInfos = (deprecations: DeprecationAPIResponse) =>
+ Object.keys(deprecations.index_settings).reduce((indexDeprecations, indexName) => {
+ return indexDeprecations.concat(
+ deprecations.index_settings[indexName].map(
+ (d) =>
+ ({
+ ...d,
+ index: indexName,
+ reindex: /Index created before/.test(d.message),
+ } as EnrichedDeprecationInfo)
+ )
+ );
+ }, [] as EnrichedDeprecationInfo[]);
const getClusterDeprecations = (deprecations: DeprecationAPIResponse, isCloudEnabled: boolean) => {
const combined = deprecations.cluster_settings
diff --git a/x-pack/plugins/upgrade_assistant/server/lib/query_default_field.test.ts b/x-pack/plugins/upgrade_assistant/server/lib/query_default_field.test.ts
deleted file mode 100644
index 5edd87b76b2c1..0000000000000
--- a/x-pack/plugins/upgrade_assistant/server/lib/query_default_field.test.ts
+++ /dev/null
@@ -1,116 +0,0 @@
-/*
- * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
- * or more contributor license agreements. Licensed under the Elastic License
- * 2.0; you may not use this file except in compliance with the Elastic License
- * 2.0.
- */
-
-import { IScopedClusterClient } from 'src/core/server';
-import { RequestEvent } from '@elastic/elasticsearch/lib/Transport';
-import { elasticsearchServiceMock } from '../../../../../src/core/server/mocks';
-import { MappingProperties } from './reindexing/types';
-
-import { addDefaultField, generateDefaultFields } from './query_default_field';
-
-const defaultFieldTypes = new Set(['keyword', 'text', 'ip']);
-
-const asApiResponse = (body: T): RequestEvent =>
- ({
- body,
- } as RequestEvent);
-
-describe('getDefaultFieldList', () => {
- it('returns dot-delimited flat list', () => {
- const mapping: MappingProperties = {
- nested1: {
- properties: {
- included2: { type: 'ip' },
- ignored2: { type: 'geopoint' },
- nested2: {
- properties: {
- included3: { type: 'keyword' },
- 'included4.keyword': { type: 'keyword' },
- },
- },
- },
- },
- ignored1: { type: 'object' },
- included1: { type: 'text' },
- };
-
- expect(generateDefaultFields(mapping, defaultFieldTypes)).toMatchInlineSnapshot(`
- Array [
- "nested1.included2",
- "nested1.nested2.included3",
- "nested1.nested2.included4.keyword",
- "included1",
- ]
- `);
- });
-});
-
-describe('fixMetricbeatIndex', () => {
- let dataClient: IScopedClusterClient;
- const mockMappings = {
- 'metricbeat-1': {
- mappings: { properties: { field1: { type: 'text' }, field2: { type: 'float' } } },
- },
- };
- const mockSettings = {
- 'metricbeat-1': {
- settings: {},
- },
- };
-
- beforeEach(() => (dataClient = elasticsearchServiceMock.createScopedClusterClient()));
-
- it('fails if index already has index.query.default_field setting', async () => {
- (dataClient.asCurrentUser.indices.getSettings as jest.Mock).mockResolvedValueOnce(
- asApiResponse({
- 'metricbeat-1': {
- settings: { index: { query: { default_field: [] } } },
- },
- })
- );
- await expect(
- addDefaultField(dataClient, 'metricbeat-1', defaultFieldTypes)
- ).rejects.toThrowErrorMatchingInlineSnapshot(
- `"Index metricbeat-1 already has index.query.default_field set"`
- );
- });
-
- it('updates index settings with default_field generated from mappings and otherFields', async () => {
- (dataClient.asCurrentUser.indices.getSettings as jest.Mock).mockResolvedValueOnce(
- asApiResponse(mockSettings)
- );
-
- (dataClient.asCurrentUser.indices.getMapping as jest.Mock).mockResolvedValueOnce(
- asApiResponse(mockMappings)
- );
-
- (dataClient.asCurrentUser.indices.putSettings as jest.Mock).mockResolvedValueOnce(
- asApiResponse({ acknowledged: true })
- );
-
- await expect(
- addDefaultField(
- dataClient,
- 'metricbeat-1',
- defaultFieldTypes,
- new Set(['fields.*', 'myCustomField'])
- )
- ).resolves.toEqual({
- body: { acknowledged: true },
- });
- expect(dataClient.asCurrentUser.indices.putSettings).toHaveBeenCalledWith({
- body: {
- index: {
- query: {
- default_field: ['field1', 'fields.*', 'myCustomField'],
- },
- },
- },
- index: 'metricbeat-1',
- });
- });
-});
diff --git a/x-pack/plugins/upgrade_assistant/server/lib/query_default_field.ts b/x-pack/plugins/upgrade_assistant/server/lib/query_default_field.ts
deleted file mode 100644
index e625b26232903..0000000000000
--- a/x-pack/plugins/upgrade_assistant/server/lib/query_default_field.ts
+++ /dev/null
@@ -1,74 +0,0 @@
-/*
- * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
- * or more contributor license agreements. Licensed under the Elastic License
- * 2.0; you may not use this file except in compliance with the Elastic License
- * 2.0.
- */
-
-import { IScopedClusterClient } from 'kibana/server';
-import Boom from '@hapi/boom';
-import { get } from 'lodash';
-
-import { MappingProperties } from './reindexing/types';
-
-/**
- * Adds the index.query.default_field setting, generated from the index's mapping.
- *
- * @param callWithRequest
- * @param request
- * @param indexName
- * @param fieldTypes - Elasticsearch field types that should be used to generate the default_field from the index mapping
- * @param otherFields - Other fields that should be included in the generated default_field that do not match `fieldTypes`
- */
-export const addDefaultField = async (
- clusterClient: IScopedClusterClient,
- indexName: string,
- fieldTypes: ReadonlySet,
- otherFields: ReadonlySet = new Set()
-) => {
- // Verify index.query.default_field is not already set.
- const { body: settings } = await clusterClient.asCurrentUser.indices.getSettings({
- index: indexName,
- });
- if (get(settings, `${indexName}.settings.index.query.default_field`)) {
- throw Boom.badRequest(`Index ${indexName} already has index.query.default_field set`);
- }
-
- // Get the mapping and generate the default_field based on `fieldTypes`
- const { body: mappingResp } = await clusterClient.asCurrentUser.indices.getMapping({
- index: indexName,
- });
- const mapping = mappingResp[indexName].mappings.properties as MappingProperties;
- const generatedDefaultFields = new Set(generateDefaultFields(mapping, fieldTypes));
-
- // Update the setting with the generated default_field
- return clusterClient.asCurrentUser.indices.putSettings({
- index: indexName,
- body: {
- index: { query: { default_field: [...generatedDefaultFields, ...otherFields] } },
- },
- });
-};
-
-/**
- * Recursively walks an index mapping and returns a flat array of dot-delimited
- * strings represent all fields that are of a type included in `DEFAULT_FIELD_TYPES`
- * @param mapping
- */
-export const generateDefaultFields = (
- mapping: MappingProperties,
- fieldTypes: ReadonlySet
-): string[] =>
- Object.getOwnPropertyNames(mapping).reduce((defaultFields, fieldName) => {
- const { type, properties } = mapping[fieldName];
-
- if (type && fieldTypes.has(type)) {
- defaultFields.push(fieldName);
- } else if (properties) {
- generateDefaultFields(properties, fieldTypes).forEach((subField) =>
- defaultFields.push(`${fieldName}.${subField}`)
- );
- }
-
- return defaultFields;
- }, [] as string[]);
diff --git a/x-pack/plugins/upgrade_assistant/server/lib/reindexing/error.ts b/x-pack/plugins/upgrade_assistant/server/lib/reindexing/error.ts
index d10242470fabb..9efe0a7fb94b5 100644
--- a/x-pack/plugins/upgrade_assistant/server/lib/reindexing/error.ts
+++ b/x-pack/plugins/upgrade_assistant/server/lib/reindexing/error.ts
@@ -13,7 +13,6 @@ import {
ReindexTaskFailed,
ReindexAlreadyInProgress,
MultipleReindexJobsFound,
- CannotReindexSystemIndexInCurrent,
ReindexCannotBeCancelled,
ReindexIsNotInQueue,
} from './error_symbols';
@@ -35,7 +34,6 @@ export const error = {
reindexTaskFailed: createErrorFactory(ReindexTaskFailed),
reindexTaskCannotBeDeleted: createErrorFactory(ReindexTaskCannotBeDeleted),
reindexAlreadyInProgress: createErrorFactory(ReindexAlreadyInProgress),
- reindexSystemIndex: createErrorFactory(CannotReindexSystemIndexInCurrent),
reindexIsNotInQueue: createErrorFactory(ReindexIsNotInQueue),
multipleReindexJobsFound: createErrorFactory(MultipleReindexJobsFound),
reindexCannotBeCancelled: createErrorFactory(ReindexCannotBeCancelled),
diff --git a/x-pack/plugins/upgrade_assistant/server/lib/reindexing/error_symbols.ts b/x-pack/plugins/upgrade_assistant/server/lib/reindexing/error_symbols.ts
index 2a7bfde931989..5bc45dfed4c98 100644
--- a/x-pack/plugins/upgrade_assistant/server/lib/reindexing/error_symbols.ts
+++ b/x-pack/plugins/upgrade_assistant/server/lib/reindexing/error_symbols.ts
@@ -12,7 +12,6 @@ export const CannotCreateIndex = Symbol('CannotCreateIndex');
export const ReindexTaskFailed = Symbol('ReindexTaskFailed');
export const ReindexTaskCannotBeDeleted = Symbol('ReindexTaskCannotBeDeleted');
export const ReindexAlreadyInProgress = Symbol('ReindexAlreadyInProgress');
-export const CannotReindexSystemIndexInCurrent = Symbol('CannotReindexSystemIndexInCurrent');
export const ReindexIsNotInQueue = Symbol('ReindexIsNotInQueue');
export const ReindexCannotBeCancelled = Symbol('ReindexCannotBeCancelled');
diff --git a/x-pack/plugins/upgrade_assistant/server/lib/reindexing/index.ts b/x-pack/plugins/upgrade_assistant/server/lib/reindexing/index.ts
index 5e53240593213..c1ff38b08678f 100644
--- a/x-pack/plugins/upgrade_assistant/server/lib/reindexing/index.ts
+++ b/x-pack/plugins/upgrade_assistant/server/lib/reindexing/index.ts
@@ -5,5 +5,5 @@
* 2.0.
*/
-export { reindexServiceFactory, isSystemIndex } from './reindex_service';
+export { reindexServiceFactory } from './reindex_service';
export { ReindexWorker } from './worker';
diff --git a/x-pack/plugins/upgrade_assistant/server/lib/reindexing/reindex_actions.ts b/x-pack/plugins/upgrade_assistant/server/lib/reindexing/reindex_actions.ts
index 798d5f7d44747..8e63367802cd9 100644
--- a/x-pack/plugins/upgrade_assistant/server/lib/reindexing/reindex_actions.ts
+++ b/x-pack/plugins/upgrade_assistant/server/lib/reindexing/reindex_actions.ts
@@ -85,14 +85,12 @@ export interface ReindexActions {
/**
* Retrieve index settings (in flat, dot-notation style) and mappings.
* @param indexName
+ * @param withTypeName
*/
- getFlatSettings(indexName: string): Promise;
-
- /**
- * Retrieve index settings (in flat, dot-notation style) and mappings with the type name included.
- * @param indexName
- */
- getFlatSettingsWithTypeName(indexName: string): Promise;
+ getFlatSettings(
+ indexName: string,
+ withTypeName?: boolean
+ ): Promise;
// ----- Functions below are for enforcing locks around groups of indices like ML or Watcher
@@ -243,10 +241,10 @@ export const reindexActionsFactory = (
return allOps;
},
- async getFlatSettings(indexName: string) {
+ async getFlatSettings(indexName: string, withTypeName?: boolean) {
let flatSettings;
- if (versionService.getMajorVersion() === 7) {
+ if (versionService.getMajorVersion() === 7 && withTypeName) {
// On 7.x, we need to get index settings with mapping type
flatSettings = await esClient.indices.get<{
[indexName: string]: FlatSettingsWithTypeName;
@@ -273,22 +271,6 @@ export const reindexActionsFactory = (
return flatSettings.body[indexName];
},
- async getFlatSettingsWithTypeName(indexName: string) {
- const { body: flatSettings } = await esClient.indices.get<{
- [indexName: string]: FlatSettingsWithTypeName;
- }>({
- index: indexName,
- flat_settings: true,
- include_type_name: true,
- });
-
- if (!flatSettings[indexName]) {
- return null;
- }
-
- return flatSettings[indexName];
- },
-
async _fetchAndLockIndexGroupDoc(indexGroup) {
const fetchDoc = async () => {
try {
diff --git a/x-pack/plugins/upgrade_assistant/server/lib/reindexing/reindex_service.test.ts b/x-pack/plugins/upgrade_assistant/server/lib/reindexing/reindex_service.test.ts
index 06e6ad9d646e8..a91cf8ddeada9 100644
--- a/x-pack/plugins/upgrade_assistant/server/lib/reindexing/reindex_service.test.ts
+++ b/x-pack/plugins/upgrade_assistant/server/lib/reindexing/reindex_service.test.ts
@@ -68,7 +68,6 @@ describe('reindexService', () => {
findReindexOperations: jest.fn(unimplemented('findReindexOperations')),
findAllByStatus: jest.fn(unimplemented('findAllInProgressOperations')),
getFlatSettings: jest.fn(unimplemented('getFlatSettings')),
- getFlatSettingsWithTypeName: jest.fn(unimplemented('getFlatSettingsWithTypeName')),
cleanupChanges: jest.fn(),
incrementIndexGroupReindexes: jest.fn(unimplemented('incrementIndexGroupReindexes')),
decrementIndexGroupReindexes: jest.fn(unimplemented('decrementIndexGroupReindexes')),
@@ -87,7 +86,7 @@ describe('reindexService', () => {
clusterClient.asCurrentUser,
actions,
log,
- licensingPluginSetup,
+ licensingPluginSetup
);
versionService.setup(mockKibanaVersion);
@@ -212,7 +211,7 @@ describe('reindexService', () => {
describe('detectReindexWarnings', () => {
it('fetches reindex warnings from flat settings', async () => {
const indexName = 'myIndex';
- actions.getFlatSettingsWithTypeName.mockResolvedValueOnce({
+ actions.getFlatSettings.mockResolvedValueOnce({
settings: {
'index.provided_name': indexName,
},
@@ -226,7 +225,7 @@ describe('reindexService', () => {
});
it('returns null if index does not exist', async () => {
- actions.getFlatSettingsWithTypeName.mockResolvedValueOnce(null);
+ actions.getFlatSettings.mockResolvedValueOnce(null);
const reindexWarnings = await service.detectReindexWarnings('myIndex');
expect(reindexWarnings).toBeNull();
});
@@ -249,12 +248,6 @@ describe('reindexService', () => {
expect(actions.createReindexOp).not.toHaveBeenCalled();
});
- it('fails if system index', async () => {
- actions.getFlatSettings.mockResolvedValueOnce({ settings: {}, mappings: {} });
- await expect(service.createReindexOperation('.myIndex')).rejects.toThrow();
- expect(actions.createReindexOp).not.toHaveBeenCalled();
- });
-
it('deletes existing operation if it failed', async () => {
clusterClient.asCurrentUser.indices.exists.mockResolvedValueOnce(asApiResponse(true));
actions.findReindexOperations.mockResolvedValueOnce({
@@ -977,7 +970,6 @@ describe('reindexService', () => {
expect(updatedOp.attributes.reindexTaskPercComplete).toEqual(1);
expect(clusterClient.asCurrentUser.delete).toHaveBeenCalledWith({
index: '.tasks',
- type: 'task',
id: 'xyz',
});
});
@@ -1022,7 +1014,6 @@ describe('reindexService', () => {
expect(updatedOp.attributes.status).toEqual(ReindexStatus.cancelled);
expect(clusterClient.asCurrentUser.delete).toHaveBeenLastCalledWith({
index: '.tasks',
- type: 'task',
id: 'xyz',
});
});
diff --git a/x-pack/plugins/upgrade_assistant/server/lib/reindexing/reindex_service.ts b/x-pack/plugins/upgrade_assistant/server/lib/reindexing/reindex_service.ts
index b6c4140bd4169..1b100b70f3750 100644
--- a/x-pack/plugins/upgrade_assistant/server/lib/reindexing/reindex_service.ts
+++ b/x-pack/plugins/upgrade_assistant/server/lib/reindexing/reindex_service.ts
@@ -18,11 +18,8 @@ import {
ReindexWarning,
} from '../../../common/types';
-
import { esIndicesStateCheck } from '../es_indices_state_check';
-import { versionService } from '../version';
-
import {
generateNewIndexName,
getReindexWarnings,
@@ -135,7 +132,7 @@ export const reindexServiceFactory = (
esClient: ElasticsearchClient,
actions: ReindexActions,
log: Logger,
- licensing: LicensingPluginSetup,
+ licensing: LicensingPluginSetup
): ReindexService => {
// ------ Utility functions
@@ -424,7 +421,6 @@ export const reindexServiceFactory = (
// Delete the task from ES .tasks index
const { body: deleteTaskResp } = await esClient.delete({
index: '.tasks',
- type: 'task',
id: taskId,
});
@@ -552,7 +548,7 @@ export const reindexServiceFactory = (
},
async detectReindexWarnings(indexName: string) {
- const flatSettings = await actions.getFlatSettingsWithTypeName(indexName);
+ const flatSettings = await actions.getFlatSettings(indexName, true);
if (!flatSettings) {
return null;
} else {
@@ -569,12 +565,6 @@ export const reindexServiceFactory = (
},
async createReindexOperation(indexName: string, opts?: { enqueue: boolean }) {
- if (isSystemIndex(indexName)) {
- throw error.reindexSystemIndex(
- `Reindexing system indices are not yet supported within this major version. Upgrade to the latest ${versionService.getMajorVersion()}.x minor version.`
- );
- }
-
const { body: indexExists } = await esClient.indices.exists({ index: indexName });
if (!indexExists) {
throw error.indexNotFound(`Index ${indexName} does not exist in this cluster.`);
@@ -773,8 +763,6 @@ export const reindexServiceFactory = (
};
};
-export const isSystemIndex = (indexName: string) => indexName.startsWith('.');
-
export const isMlIndex = (indexName: string) => {
const sourceName = sourceNameForIndex(indexName);
return ML_INDICES.indexOf(sourceName) >= 0;
diff --git a/x-pack/plugins/upgrade_assistant/server/lib/reindexing/types.ts b/x-pack/plugins/upgrade_assistant/server/lib/reindexing/types.ts
index c26dbbb1bf4c0..569316e276e43 100644
--- a/x-pack/plugins/upgrade_assistant/server/lib/reindexing/types.ts
+++ b/x-pack/plugins/upgrade_assistant/server/lib/reindexing/types.ts
@@ -28,10 +28,7 @@ export interface FlatSettings {
};
}
-<<<<<<< HEAD
-=======
// Specific to 7.x-8 upgrade
->>>>>>> fe6bd2ecbb4... [Upgrade Assistant] Align code between branches (#91862)
export interface FlatSettingsWithTypeName {
settings: {
[key: string]: string;
diff --git a/x-pack/plugins/upgrade_assistant/server/lib/reindexing/worker.ts b/x-pack/plugins/upgrade_assistant/server/lib/reindexing/worker.ts
index 6d55b1e8007f0..08b9486e8394a 100644
--- a/x-pack/plugins/upgrade_assistant/server/lib/reindexing/worker.ts
+++ b/x-pack/plugins/upgrade_assistant/server/lib/reindexing/worker.ts
@@ -52,7 +52,7 @@ export class ReindexWorker {
private credentialStore: CredentialStore,
private clusterClient: IClusterClient,
log: Logger,
- private licensing: LicensingPluginSetup,
+ private licensing: LicensingPluginSetup
) {
this.log = log.get('reindex_worker');
if (ReindexWorker.workerSingleton) {
@@ -65,7 +65,7 @@ export class ReindexWorker {
callAsInternalUser,
reindexActionsFactory(this.client, callAsInternalUser),
log,
- this.licensing,
+ this.licensing
);
ReindexWorker.workerSingleton = this;
@@ -150,12 +150,7 @@ export class ReindexWorker {
const scopedClusterClient = this.clusterClient.asScoped(fakeRequest);
const callAsCurrentUser = scopedClusterClient.asCurrentUser;
const actions = reindexActionsFactory(this.client, callAsCurrentUser);
- return reindexServiceFactory(
- callAsCurrentUser,
- actions,
- this.log,
- this.licensing,
- );
+ return reindexServiceFactory(callAsCurrentUser, actions, this.log, this.licensing);
};
private updateInProgressOps = async () => {
@@ -231,12 +226,7 @@ export class ReindexWorker {
const callAsCurrentUser = scopedClusterClient.asCurrentUser;
const actions = reindexActionsFactory(this.client, callAsCurrentUser);
- const service = reindexServiceFactory(
- callAsCurrentUser,
- actions,
- this.log,
- this.licensing,
- );
+ const service = reindexServiceFactory(callAsCurrentUser, actions, this.log, this.licensing);
reindexOp = await swallowExceptions(service.processNextStep, this.log)(reindexOp);
// Update credential store with most recent state.
diff --git a/x-pack/plugins/upgrade_assistant/server/plugin.ts b/x-pack/plugins/upgrade_assistant/server/plugin.ts
index 1c7483f8ebc35..c6da641f4092f 100644
--- a/x-pack/plugins/upgrade_assistant/server/plugin.ts
+++ b/x-pack/plugins/upgrade_assistant/server/plugin.ts
@@ -27,7 +27,6 @@ import { registerUpgradeAssistantUsageCollector } from './lib/telemetry';
import { versionService } from './lib/version';
import { registerClusterCheckupRoutes } from './routes/cluster_checkup';
import { registerDeprecationLoggingRoutes } from './routes/deprecation_logging';
-import { registerQueryDefaultFieldRoutes } from './routes/query_default_field';
import { registerReindexIndicesRoutes, createReindexWorker } from './routes/reindex_indices';
import { registerTelemetryRoutes } from './routes/telemetry';
import { telemetrySavedObjectType, reindexOperationSavedObjectType } from './saved_object_types';
@@ -112,7 +111,6 @@ export class UpgradeAssistantServerPlugin implements Plugin {
registerReindexIndicesRoutes(dependencies, this.getWorker.bind(this));
// Bootstrap the needed routes and the collector for the telemetry
registerTelemetryRoutes(dependencies);
- registerQueryDefaultFieldRoutes(dependencies);
if (usageCollection) {
getStartServices().then(([{ savedObjects: savedObjectsService, elasticsearch }]) => {
@@ -125,7 +123,7 @@ export class UpgradeAssistantServerPlugin implements Plugin {
}
}
- async start({ savedObjects, elasticsearch }: CoreStart) {
+ start({ savedObjects, elasticsearch }: CoreStart) {
this.savedObjectsServiceStart = savedObjects;
// The ReindexWorker uses a map of request headers that contain the authentication credentials
@@ -145,7 +143,7 @@ export class UpgradeAssistantServerPlugin implements Plugin {
),
});
- this.worker!.start();
+ this.worker.start();
}
stop(): void {
diff --git a/x-pack/plugins/upgrade_assistant/server/routes/cluster_checkup.ts b/x-pack/plugins/upgrade_assistant/server/routes/cluster_checkup.ts
index fc3ad98401594..b4dae6ec385b4 100644
--- a/x-pack/plugins/upgrade_assistant/server/routes/cluster_checkup.ts
+++ b/x-pack/plugins/upgrade_assistant/server/routes/cluster_checkup.ts
@@ -11,12 +11,7 @@ import { RouteDependencies } from '../types';
import { reindexActionsFactory } from '../lib/reindexing/reindex_actions';
import { reindexServiceFactory } from '../lib/reindexing';
-export function registerClusterCheckupRoutes({
- cloud,
- router,
- licensing,
- log,
-}: RouteDependencies) {
+export function registerClusterCheckupRoutes({ cloud, router, licensing, log }: RouteDependencies) {
const isCloudEnabled = Boolean(cloud?.isCloudEnabled);
router.get(
diff --git a/x-pack/plugins/upgrade_assistant/server/routes/query_default_field.test.mocks.ts b/x-pack/plugins/upgrade_assistant/server/routes/query_default_field.test.mocks.ts
deleted file mode 100644
index 730e750a8ffb6..0000000000000
--- a/x-pack/plugins/upgrade_assistant/server/routes/query_default_field.test.mocks.ts
+++ /dev/null
@@ -1,12 +0,0 @@
-/*
- * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
- * or more contributor license agreements. Licensed under the Elastic License
- * 2.0; you may not use this file except in compliance with the Elastic License
- * 2.0.
- */
-
-export const mockAddDefaultField = jest.fn();
-
-jest.mock('../lib/query_default_field', () => ({
- addDefaultField: mockAddDefaultField,
-}));
diff --git a/x-pack/plugins/upgrade_assistant/server/routes/query_default_field.test.ts b/x-pack/plugins/upgrade_assistant/server/routes/query_default_field.test.ts
deleted file mode 100644
index 081e959ff08e2..0000000000000
--- a/x-pack/plugins/upgrade_assistant/server/routes/query_default_field.test.ts
+++ /dev/null
@@ -1,86 +0,0 @@
-/*
- * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
- * or more contributor license agreements. Licensed under the Elastic License
- * 2.0; you may not use this file except in compliance with the Elastic License
- * 2.0.
- */
-
-import { kibanaResponseFactory } from 'src/core/server';
-import { createMockRouter, routeHandlerContextMock } from './__mocks__/routes.mock';
-import { createRequestMock } from './__mocks__/request.mock';
-import { mockAddDefaultField } from './query_default_field.test.mocks';
-
-jest.mock('../lib/es_version_precheck', () => ({
- versionCheckHandlerWrapper: (a: any) => a,
-}));
-
-import { registerQueryDefaultFieldRoutes } from './query_default_field';
-
-describe('add query default field API', () => {
- let dependencies: any;
-
- beforeEach(() => {
- dependencies = {
- router: createMockRouter(),
- };
- mockAddDefaultField.mockClear();
- registerQueryDefaultFieldRoutes(dependencies);
- });
-
- afterEach(() => {
- jest.resetAllMocks();
- });
-
- it('calls addDefaultField with index, field types, and other fields', async () => {
- mockAddDefaultField.mockResolvedValueOnce({ acknowledged: true });
- const resp = await dependencies.router.getHandler({
- method: 'post',
- pathPattern: '/api/upgrade_assistant/add_query_default_field/{indexName}',
- })(
- routeHandlerContextMock,
- createRequestMock({
- params: { indexName: 'myIndex' },
- body: {
- fieldTypes: ['text', 'boolean'],
- otherFields: ['myCustomField'],
- },
- }),
- kibanaResponseFactory
- );
-
- expect(mockAddDefaultField).toHaveBeenCalledWith(
- routeHandlerContextMock.core.elasticsearch.client,
- 'myIndex',
- new Set(['text', 'boolean']),
- new Set(['myCustomField'])
- );
- expect(resp.status).toEqual(200);
- expect(resp.payload).toEqual({ acknowledged: true });
- });
-
- it('calls addDefaultField with index, field types if other fields is not specified', async () => {
- mockAddDefaultField.mockResolvedValueOnce({ acknowledged: true });
- const resp = await dependencies.router.getHandler({
- method: 'post',
- pathPattern: '/api/upgrade_assistant/add_query_default_field/{indexName}',
- })(
- routeHandlerContextMock,
- createRequestMock({
- params: { indexName: 'myIndex' },
- body: {
- fieldTypes: ['text', 'boolean'],
- },
- }),
- kibanaResponseFactory
- );
-
- expect(mockAddDefaultField).toHaveBeenCalledWith(
- routeHandlerContextMock.core.elasticsearch.client,
- 'myIndex',
- new Set(['text', 'boolean']),
- undefined
- );
- expect(resp.status).toEqual(200);
- expect(resp.payload).toEqual({ acknowledged: true });
- });
-});
diff --git a/x-pack/plugins/upgrade_assistant/server/routes/query_default_field.ts b/x-pack/plugins/upgrade_assistant/server/routes/query_default_field.ts
deleted file mode 100644
index 5942dda56db9d..0000000000000
--- a/x-pack/plugins/upgrade_assistant/server/routes/query_default_field.ts
+++ /dev/null
@@ -1,69 +0,0 @@
-/*
- * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
- * or more contributor license agreements. Licensed under the Elastic License
- * 2.0; you may not use this file except in compliance with the Elastic License
- * 2.0.
- */
-
-import { schema } from '@kbn/config-schema';
-import { addDefaultField } from '../lib/query_default_field';
-import { versionCheckHandlerWrapper } from '../lib/es_version_precheck';
-import { RouteDependencies } from '../types';
-
-/**
- * Adds routes for detecting and fixing 6.x Metricbeat indices that need the
- * `index.query.default_field` index setting added.
- *
- * @param server
- */
-export function registerQueryDefaultFieldRoutes({ router }: RouteDependencies) {
- router.post(
- {
- path: '/api/upgrade_assistant/add_query_default_field/{indexName}',
- validate: {
- params: schema.object({
- indexName: schema.string(),
- }),
- body: schema.object({
- fieldTypes: schema.arrayOf(schema.string()),
- otherFields: schema.arrayOf(schema.string(), { defaultValue: undefined }),
- }),
- },
- },
- versionCheckHandlerWrapper(
- async (
- {
- core: {
- elasticsearch: { client },
- },
- },
- request,
- response
- ) => {
- try {
- const { indexName } = request.params;
- const { fieldTypes, otherFields } = request.body as {
- fieldTypes: string[];
- otherFields?: string[];
- };
-
- return response.ok({
- body: await addDefaultField(
- client,
- indexName,
- new Set(fieldTypes),
- otherFields ? new Set(otherFields) : undefined
- ),
- });
- } catch (e) {
- const status = e.status || e.statusCode;
- if (status === 403) {
- return response.forbidden({ body: e });
- }
-
- throw e;
- }
- }
- )
- );
-}
diff --git a/x-pack/plugins/upgrade_assistant/server/routes/reindex_indices/reindex_indices.ts b/x-pack/plugins/upgrade_assistant/server/routes/reindex_indices/reindex_indices.ts
index 28730012b51b6..d36f8225ffa3b 100644
--- a/x-pack/plugins/upgrade_assistant/server/routes/reindex_indices/reindex_indices.ts
+++ b/x-pack/plugins/upgrade_assistant/server/routes/reindex_indices/reindex_indices.ts
@@ -33,7 +33,6 @@ import {
ReindexCannotBeCancelled,
ReindexTaskCannotBeDeleted,
ReindexTaskFailed,
- CannotReindexSystemIndexInCurrent,
} from '../../lib/reindexing/error_symbols';
import { reindexHandler } from './reindex_handler';
@@ -55,13 +54,7 @@ export function createReindexWorker({
licensing,
}: CreateReindexWorker) {
const esClient = elasticsearchService.client;
- return new ReindexWorker(
- savedObjects,
- credentialStore,
- esClient,
- logger,
- licensing,
- );
+ return new ReindexWorker(savedObjects, credentialStore, esClient, logger, licensing);
}
const mapAnyErrorToKibanaHttpResponse = (e: any) => {
@@ -81,9 +74,6 @@ const mapAnyErrorToKibanaHttpResponse = (e: any) => {
case MultipleReindexJobsFound:
case ReindexCannotBeCancelled:
return kibanaResponseFactory.badRequest({ body: e.message });
- case CannotReindexSystemIndexInCurrent:
- // Not implemented (specific to current version)
- return kibanaResponseFactory.customError({ body: e.message, statusCode: 501 });
default:
// nothing matched
}
diff --git a/x-pack/test/upgrade_assistant_integration/upgrade_assistant/index.js b/x-pack/test/upgrade_assistant_integration/upgrade_assistant/index.js
index 4a935b01fde6f..1a7090a3cbdfb 100644
--- a/x-pack/test/upgrade_assistant_integration/upgrade_assistant/index.js
+++ b/x-pack/test/upgrade_assistant_integration/upgrade_assistant/index.js
@@ -9,7 +9,6 @@ export default function ({ loadTestFile }) {
describe('upgrade assistant', function () {
this.tags('ciGroup7');
- loadTestFile(require.resolve('./query_default_field'));
loadTestFile(require.resolve('./reindexing'));
});
}
diff --git a/x-pack/test/upgrade_assistant_integration/upgrade_assistant/query_default_field.js b/x-pack/test/upgrade_assistant_integration/upgrade_assistant/query_default_field.js
deleted file mode 100644
index 1b579c90cf4c9..0000000000000
--- a/x-pack/test/upgrade_assistant_integration/upgrade_assistant/query_default_field.js
+++ /dev/null
@@ -1,48 +0,0 @@
-/*
- * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
- * or more contributor license agreements. Licensed under the Elastic License
- * 2.0; you may not use this file except in compliance with the Elastic License
- * 2.0.
- */
-
-import expect from '@kbn/expect';
-
-export default function ({ getService }) {
- const supertest = getService('supertest');
- const esArchiver = getService('esArchiver');
- const es = getService('es');
-
- const indexName = `metricbeat-6.7.0-2019.03.11`;
-
- describe('add default_field setting', () => {
- beforeEach(async () => {
- await esArchiver.load('upgrade_assistant/metricbeat');
- });
-
- afterEach(async () => {
- await esArchiver.unload('upgrade_assistant/metricbeat');
- });
-
- it('adds index.query.default_field to metricbeat index', async () => {
- const { body } = await supertest
- .post(`/api/upgrade_assistant/add_query_default_field/${indexName}`)
- .set('kbn-xsrf', 'xxx')
- .send({ fieldTypes: ['text', 'keyword', 'ip'], otherFields: ['fields.*'] })
- .expect(200);
- expect(body.body.acknowledged).to.be(true);
-
- // The index.query.default_field setting should now be set
- const { body: settingsResp } = await es.indices.getSettings({ index: indexName });
- expect(settingsResp[indexName].settings.index.query.default_field).to.not.be(undefined);
-
- // Deprecation message should be gone
- const { body: uaBody } = await supertest.get('/api/upgrade_assistant/status').expect(200);
- const depMessage = uaBody.indices.find(
- (dep) =>
- dep.index === indexName &&
- dep.message === 'Number of fields exceeds automatic field expansion limit'
- );
- expect(depMessage).to.be(undefined);
- });
- });
-}