diff --git a/x-pack/plugins/upgrade_assistant/common/types.ts b/x-pack/plugins/upgrade_assistant/common/types.ts index 4902a1668782a9..6d83bdc5f36e9e 100644 --- a/x-pack/plugins/upgrade_assistant/common/types.ts +++ b/x-pack/plugins/upgrade_assistant/common/types.ts @@ -93,13 +93,10 @@ export interface ReindexOperation extends SavedObjectAttributes { export type ReindexSavedObject = SavedObject; export enum ReindexWarning { - // 6.0 -> 7.0 warnings, now unused - allField, - booleanFields, - // 7.0 -> 8.0 warnings - apmReindex, customTypeName, + + // 8.0 -> 9.0 warnings } export enum IndexGroup { @@ -184,7 +181,6 @@ export interface EnrichedDeprecationInfo extends DeprecationInfo { index?: string; node?: string; reindex?: boolean; - needsDefaultFields?: boolean; /** * Indicate what blockers have been detected for calling reindex * against this index. diff --git a/x-pack/plugins/upgrade_assistant/kibana.json b/x-pack/plugins/upgrade_assistant/kibana.json index 0a3da4c055b1c6..c4c6f23611f2bd 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 8810569027cc85..ee722a39372169 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 @@ -18,7 +18,7 @@ import { OverviewTab } from './tabs/overview'; const promisesToResolve = () => new Promise((resolve) => setTimeout(resolve, 0)); const mockHttp = httpServiceMock.createSetupContract(); -const mockKibanaVersion = new SemVer('7.0.0'); +const mockKibanaVersion = new SemVer('8.0.0'); jest.mock('../app_context', () => { return { diff --git a/x-pack/plugins/upgrade_assistant/public/application/components/tabs/checkup/__snapshots__/checkup_tab.test.tsx.snap b/x-pack/plugins/upgrade_assistant/public/application/components/tabs/checkup/__snapshots__/checkup_tab.test.tsx.snap index 8d4e2d8535846a..bac67bf722ea74 100644 --- a/x-pack/plugins/upgrade_assistant/public/application/components/tabs/checkup/__snapshots__/checkup_tab.test.tsx.snap +++ b/x-pack/plugins/upgrade_assistant/public/application/components/tabs/checkup/__snapshots__/checkup_tab.test.tsx.snap @@ -14,7 +14,7 @@ exports[`CheckupTab render with deprecations 1`] = ` id="xpack.upgradeAssistant.checkupTab.tabDetail" values={ Object { - "nextEsVersion": "8.x", + "nextEsVersion": "9.x", "strongCheckupLabel": index , @@ -298,7 +298,7 @@ exports[`CheckupTab render with error 1`] = ` id="xpack.upgradeAssistant.checkupTab.tabDetail" values={ Object { - "nextEsVersion": "8.x", + "nextEsVersion": "9.x", "strongCheckupLabel": index , @@ -366,7 +366,7 @@ exports[`CheckupTab render without deprecations 1`] = ` id="xpack.upgradeAssistant.checkupTab.tabDetail" values={ Object { - "nextEsVersion": "8.x", + "nextEsVersion": "9.x", "strongCheckupLabel": index , 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 feffd4f7853cd8..1ed1e0b01f65b4 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 @@ -22,7 +22,7 @@ const defaultProps = { setSelectedTabIndex: jest.fn(), }; -const mockKibanaVersion = new SemVer('7.0.0'); +const mockKibanaVersion = new SemVer('8.0.0'); jest.mock('../../../app_context', () => { return { 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 dd69263b1c8565..d71556503f19d1 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,16 +17,13 @@ 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'; interface DeprecationCellProps { items?: Array<{ title?: string; body: string }>; - indexName?: string; - reindex?: boolean; - needsDefaultFields?: boolean; + reindexIndexName?: string; docUrl?: string; headline?: string; healthColor?: string; @@ -40,9 +37,7 @@ interface DeprecationCellProps { export const DeprecationCell: FunctionComponent = ({ headline, healthColor, - indexName, - reindex, - needsDefaultFields, + reindexIndexName, docUrl, items = [], children, @@ -85,28 +80,20 @@ export const DeprecationCell: FunctionComponent = ({ ))} - {reindex && ( + {reindexIndexName && ( {({ http, docLinks }) => ( )} )} - - {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 327051c6e60925..00000000000000 --- 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 d7925655b556bc..418ab12d9c9157 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'; @@ -20,7 +19,6 @@ const PAGE_SIZES = [10, 25, 50, 100, 250, 500, 1000]; export interface IndexDeprecationDetails { index: string; reindex: boolean; - needsDefaultFields: boolean; blockerForReindexing?: EnrichedDeprecationInfo['blockerForReindexing']; details?: string; } @@ -145,11 +143,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 showActionsColumn = Boolean(indices.find((i) => i.reindex === true)); + + if (showActionsColumn === false) { return null; } @@ -157,28 +155,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/list.test.tsx b/x-pack/plugins/upgrade_assistant/public/application/components/tabs/checkup/deprecations/list.test.tsx index f302ab9e3a1c42..0bd930484af040 100644 --- a/x-pack/plugins/upgrade_assistant/public/application/components/tabs/checkup/deprecations/list.test.tsx +++ b/x-pack/plugins/upgrade_assistant/public/application/components/tabs/checkup/deprecations/list.test.tsx @@ -75,14 +75,12 @@ describe('DeprecationList', () => { "blockerForReindexing": undefined, "details": undefined, "index": "0", - "needsDefaultFields": false, "reindex": false, }, Object { "blockerForReindexing": undefined, "details": undefined, "index": "1", - "needsDefaultFields": false, "reindex": false, }, ] diff --git a/x-pack/plugins/upgrade_assistant/public/application/components/tabs/checkup/deprecations/list.tsx b/x-pack/plugins/upgrade_assistant/public/application/components/tabs/checkup/deprecations/list.tsx index 27eb1849821a29..a3e024ee546696 100644 --- a/x-pack/plugins/upgrade_assistant/public/application/components/tabs/checkup/deprecations/list.tsx +++ b/x-pack/plugins/upgrade_assistant/public/application/components/tabs/checkup/deprecations/list.tsx @@ -35,9 +35,7 @@ const MessageDeprecation: FunctionComponent<{ deprecation: EnrichedDeprecationIn reindexBlocker={deprecation.blockerForReindexing} headline={deprecation.message} healthColor={COLOR_MAP[deprecation.level]} - indexName={deprecation.index} - reindex={deprecation.reindex} - needsDefaultFields={deprecation.needsDefaultFields} + reindexIndexName={deprecation.reindex ? deprecation.index! : undefined} docUrl={deprecation.url} items={items} /> @@ -98,7 +96,6 @@ export const DeprecationList: FunctionComponent<{ index: dep.index!, details: dep.details, reindex: dep.reindex === true, - needsDefaultFields: dep.needsDefaultFields === true, blockerForReindexing: dep.blockerForReindexing, })); return ; diff --git a/x-pack/plugins/upgrade_assistant/public/application/components/tabs/checkup/deprecations/reindex/button.tsx b/x-pack/plugins/upgrade_assistant/public/application/components/tabs/checkup/deprecations/reindex/button.tsx index 5a2910c0f94a0e..1a99eca8160072 100644 --- a/x-pack/plugins/upgrade_assistant/public/application/components/tabs/checkup/deprecations/reindex/button.tsx +++ b/x-pack/plugins/upgrade_assistant/public/application/components/tabs/checkup/deprecations/reindex/button.tsx @@ -179,7 +179,6 @@ export class ReindexButton extends React.Component } onChange={[Function]} - warning={3} - /> - - } - documentationUrl="https://www.elastic.co/guide/en/observability/master/whats-new.html" - label={ - - } - onChange={[Function]} - warning={2} + warning={0} /> diff --git a/x-pack/plugins/upgrade_assistant/public/application/components/tabs/checkup/deprecations/reindex/flyout/checklist_step.test.tsx b/x-pack/plugins/upgrade_assistant/public/application/components/tabs/checkup/deprecations/reindex/flyout/checklist_step.test.tsx index 16c1de620233d8..4080bcacd59b2c 100644 --- a/x-pack/plugins/upgrade_assistant/public/application/components/tabs/checkup/deprecations/reindex/flyout/checklist_step.test.tsx +++ b/x-pack/plugins/upgrade_assistant/public/application/components/tabs/checkup/deprecations/reindex/flyout/checklist_step.test.tsx @@ -22,11 +22,6 @@ describe('ChecklistFlyout', () => { onConfirmInputChange: jest.fn(), startReindex: jest.fn(), cancelReindex: jest.fn(), - http: { - basePath: { - prepend: jest.fn(), - }, - } as any, renderGlobalCallouts: jest.fn(), reindexState: { loadingState: LoadingState.Success, 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 6ea97479fbf6d5..fc4bdcc130e25d 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 @@ -7,7 +7,6 @@ import React, { Fragment } from 'react'; -import { HttpSetup } from 'src/core/public'; import { EuiButton, EuiButtonEmpty, @@ -16,13 +15,12 @@ import { EuiFlexItem, EuiFlyoutBody, EuiFlyoutFooter, - EuiLink, EuiSpacer, EuiTitle, } from '@elastic/eui'; import { FormattedMessage } from '@kbn/i18n/react'; -import { ReindexStatus, ReindexWarning } from '../../../../../../../../common/types'; +import { ReindexStatus } from '../../../../../../../../common/types'; import { LoadingState } from '../../../../../types'; import { ReindexState } from '../polling_service'; import { ReindexProgress } from './progress'; @@ -76,9 +74,8 @@ export const ChecklistFlyoutStep: React.FunctionComponent<{ reindexState: ReindexState; startReindex: () => void; cancelReindex: () => void; - http: HttpSetup; -}> = ({ closeFlyout, reindexState, startReindex, cancelReindex, http, renderGlobalCallouts }) => { - const { loadingState, status, hasRequiredPrivileges, reindexWarnings } = reindexState; +}> = ({ closeFlyout, reindexState, startReindex, cancelReindex, renderGlobalCallouts }) => { + const { loadingState, status, hasRequiredPrivileges } = reindexState; const loading = loadingState === LoadingState.Loading || status === ReindexStatus.inProgress; return ( @@ -135,34 +132,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/container.tsx b/x-pack/plugins/upgrade_assistant/public/application/components/tabs/checkup/deprecations/reindex/flyout/container.tsx index 8da3b474a4c0d3..2f776f3937b502 100644 --- a/x-pack/plugins/upgrade_assistant/public/application/components/tabs/checkup/deprecations/reindex/flyout/container.tsx +++ b/x-pack/plugins/upgrade_assistant/public/application/components/tabs/checkup/deprecations/reindex/flyout/container.tsx @@ -6,8 +6,6 @@ */ import React from 'react'; - -import { HttpSetup } from 'src/core/public'; import { DocLinksStart } from 'kibana/public'; import { i18n } from '@kbn/i18n'; import { FormattedMessage } from '@kbn/i18n/react'; @@ -34,7 +32,6 @@ enum ReindexFlyoutStep { interface ReindexFlyoutProps { indexName: string; - http: HttpSetup; closeFlyout: () => void; reindexState: ReindexState; startReindex: () => void; @@ -47,12 +44,8 @@ interface ReindexFlyoutState { currentFlyoutStep: ReindexFlyoutStep; } -// eslint-disable-next-line @typescript-eslint/naming-convention -const getOpenAndCloseIndexDocLink = ({ ELASTIC_WEBSITE_URL, DOC_LINK_VERSION }: DocLinksStart) => ( - +const getOpenAndCloseIndexDocLink = (docLinks: DocLinksStart) => ( + {i18n.translate( 'xpack.upgradeAssistant.checkupTab.reindexing.flyout.openAndCloseDocumentation', { defaultMessage: 'documentation' } @@ -141,7 +134,6 @@ export class ReindexFlyout extends React.Component globalCallout} closeFlyout={closeFlyout} reindexState={reindexState} 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 0ebf42df53188b..77ab74452cc44e 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 @@ -28,7 +28,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(), }; @@ -48,10 +48,6 @@ describe('WarningsFlyoutStep', () => { 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(); 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 f7a640ebe7c828..fed481ef8bdab4 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 @@ -104,7 +104,6 @@ export const WarningsFlyoutStep: React.FunctionComponent - {warnings.includes(ReindexWarning.allField) && ( - _all, - }} - /> - } - description={ - _all, - }} - /> - } - documentationUrl={`${esDocBasePath}/6.0/breaking_60_mappings_changes.html#_the_literal__all_literal_meta_field_is_now_disabled_by_default`} - /> - )} - {warnings.includes(ReindexWarning.customTypeName) && ( )} - - {warnings.includes(ReindexWarning.apmReindex) && ( - - } - description={ - - } - documentationUrl={`${observabilityDocBasePath}/master/whats-new.html`} - /> - )} 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 7491fb38b849f0..244fc96acd1943 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/apm/extract_index_patterns.ts b/x-pack/plugins/upgrade_assistant/server/lib/apm/extract_index_patterns.ts deleted file mode 100644 index 163373bd7f419a..00000000000000 --- 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 74d36140175fff..00000000000000 --- 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 8c689df78e555f..00000000000000 --- 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 f518b824f11083..00000000000000 --- 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.test.ts b/x-pack/plugins/upgrade_assistant/server/lib/es_migration_apis.test.ts index c14ff5b842fd92..9ab8d0aa7cffb6 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 4985cad8bd7504..6e357fd755c82f 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,23 +12,18 @@ import { UpgradeAssistantStatus, } from '../../common/types'; -import { getDeprecatedApmIndices } from './apm'; -import { isSystemIndex } from './reindexing'; - import { esIndicesStateCheck } from './es_indices_state_check'; export async function getUpgradeAssistantStatus( dataClient: IScopedClusterClient, - isCloudEnabled: boolean, - apmIndices: string[] + isCloudEnabled: boolean ): Promise { - const [{ body: deprecations }, apmIndexDeprecations] = await Promise.all([ - dataClient.asCurrentUser.migration.deprecations(), - getDeprecatedApmIndices(dataClient, apmIndices), - ]); + const { + body: deprecations, + } = await dataClient.asCurrentUser.migration.deprecations(); const cluster = getClusterDeprecations(deprecations, isCloudEnabled); - const indices = getCombinedIndexInfos(deprecations, apmIndexDeprecations); + const indices = getCombinedIndexInfos(deprecations); const indexNames = indices.map(({ index }) => index!); @@ -53,37 +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, - 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( - (d) => - ({ - ...d, - index: indexName, - reindex: /Index created before/.test(d.message) && !apmIndices.has(indexName), - 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. Note, we're still including APM depercations below. - .filter((deprecation) => !isSystemIndex(deprecation.index!)) - .concat(apmIndexDeprecations) - ); -}; +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 5edd87b76b2c15..00000000000000 --- 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 e625b262329033..00000000000000 --- 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 d10242470fabba..9efe0a7fb94b5f 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 2a7bfde9319890..5bc45dfed4c98a 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 5e532405932130..c1ff38b08678ff 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/index_settings.ts b/x-pack/plugins/upgrade_assistant/server/lib/reindexing/index_settings.ts index 2391b01506c797..fade0f2ba31a16 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,7 +7,6 @@ import { flow, omit } from 'lodash'; import { ReindexWarning } from '../../../common/types'; -import { isLegacyApmIndex } from '../apm'; import { versionService } from '../version'; import { FlatSettings, FlatSettingsWithTypeName } from './types'; @@ -76,23 +75,12 @@ export const generateNewIndexName = (indexName: string): string => { * Returns an array of warnings that should be displayed to user before reindexing begins. * @param flatSettings */ -export const getReindexWarnings = ( - flatSettings: FlatSettingsWithTypeName, - apmIndexPatterns: string[] = [] -): ReindexWarning[] => { - const indexName = flatSettings.settings['index.provided_name']; - const typeName = Object.getOwnPropertyNames(flatSettings.mappings)[0]; - const apmReindexWarning = isLegacyApmIndex( - indexName, - apmIndexPatterns, - flatSettings.mappings[typeName] - ); +export const getReindexWarnings = (flatSettings: FlatSettingsWithTypeName): ReindexWarning[] => { const typeNameWarning = usesCustomTypeName(flatSettings); - const warnings = [ - [ReindexWarning.apmReindex, apmReindexWarning], - [ReindexWarning.customTypeName, typeNameWarning], - ] as Array<[ReindexWarning, boolean]>; + const warnings = [[ReindexWarning.customTypeName, typeNameWarning]] as Array< + [ReindexWarning, boolean] + >; return warnings.filter(([_, applies]) => applies).map(([warning, _]) => warning); }; 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 90ff699d79a725..6823c3227ef1f3 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 @@ -22,8 +22,6 @@ import { } from '../../../common/types'; 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 { esIndicesStateCheck } from '../es_indices_state_check'; @@ -88,8 +86,7 @@ describe('reindexService', () => { clusterClient.asCurrentUser, actions, log, - licensingPluginSetup, - ['apm-*'] + licensingPluginSetup ); versionService.setup(MOCK_VERSION_STRING); @@ -251,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({ @@ -846,46 +837,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 +909,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); @@ -1057,7 +970,6 @@ describe('reindexService', () => { expect(updatedOp.attributes.reindexTaskPercComplete).toEqual(1); expect(clusterClient.asCurrentUser.delete).toHaveBeenCalledWith({ index: '.tasks', - type: 'task', id: 'xyz', }); }); @@ -1102,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 92eab9be21d959..297c672df6f144 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,6 @@ import { ReindexStep, ReindexWarning, } from '../../../common/types'; -import { apmReindexScript, isLegacyApmIndex } from '../apm'; -import apmMappings from '../apm/mapping.json'; import { esIndicesStateCheck } from '../es_indices_state_check'; @@ -136,8 +134,7 @@ export const reindexServiceFactory = ( esClient: ElasticsearchClient, actions: ReindexActions, log: Logger, - licensing: LicensingPluginSetup, - apmIndexPatterns: string[] = [] + licensing: LicensingPluginSetup ): ReindexService => { // ------ Utility functions @@ -318,13 +315,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 +349,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, { @@ -437,7 +423,6 @@ export const reindexServiceFactory = ( // Delete the task from ES .tasks index const { body: deleteTaskResp } = await esClient.delete({ index: '.tasks', - type: 'task', id: taskId, }); @@ -569,7 +554,7 @@ export const reindexServiceFactory = ( if (!flatSettings) { return null; } else { - return getReindexWarnings(flatSettings, apmIndexPatterns); + return getReindexWarnings(flatSettings); } }, @@ -582,12 +567,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.`); @@ -786,8 +765,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/worker.ts b/x-pack/plugins/upgrade_assistant/server/lib/reindexing/worker.ts index 1163f36733287b..233d1c88001d29 100644 --- a/x-pack/plugins/upgrade_assistant/server/lib/reindexing/worker.ts +++ b/x-pack/plugins/upgrade_assistant/server/lib/reindexing/worker.ts @@ -52,8 +52,7 @@ export class ReindexWorker { private credentialStore: CredentialStore, private clusterClient: IClusterClient, log: Logger, - private licensing: LicensingPluginSetup, - private apmIndexPatterns: string[] + private licensing: LicensingPluginSetup ) { this.log = log.get('reindex_worker'); if (ReindexWorker.workerSingleton) { @@ -66,8 +65,7 @@ export class ReindexWorker { callAsInternalUser, reindexActionsFactory(this.client, callAsInternalUser), log, - this.licensing, - apmIndexPatterns + this.licensing ); ReindexWorker.workerSingleton = this; @@ -152,13 +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, - this.apmIndexPatterns - ); + return reindexServiceFactory(callAsCurrentUser, actions, this.log, this.licensing); }; private updateInProgressOps = async () => { @@ -227,20 +219,7 @@ export class ReindexWorker { } } - // Setup a ReindexService specific to these credentials. - const fakeRequest: FakeRequest = { headers: credential }; - - const scopedClusterClient = this.clusterClient.asScoped(fakeRequest); - const callAsCurrentUser = scopedClusterClient.asCurrentUser; - const actions = reindexActionsFactory(this.client, callAsCurrentUser); - - const service = reindexServiceFactory( - callAsCurrentUser, - actions, - this.log, - this.licensing, - this.apmIndexPatterns - ); + const service = this.getCredentialScopedReindexService(credential); 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 b6b9b5390b0047..c6da641f4092f3 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'; @@ -31,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'; @@ -41,7 +36,6 @@ import { RouteDependencies } from './types'; interface PluginsSetup { usageCollection: UsageCollectionSetup; licensing: LicensingPluginSetup; - apmOss: APMOSSPluginSetup; features: FeaturesPluginSetup; cloud?: CloudSetup; } @@ -53,7 +47,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 +67,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 +92,6 @@ export class UpgradeAssistantServerPlugin implements Plugin { const dependencies: RouteDependencies = { cloud, router, - apmOSS, credentialStore: this.credentialStore, log: this.logger, getSavedObjectsService: () => { @@ -120,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 }]) => { @@ -133,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 @@ -143,10 +133,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,10 +141,9 @@ export class UpgradeAssistantServerPlugin implements Plugin { savedObjects: new SavedObjectsClient( this.savedObjectsServiceStart.createInternalRepository() ), - apmIndexPatterns, }); - this.worker!.start(); + this.worker.start(); } stop(): void { 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 23e0d31d4bcbb6..c2bb27ce995ebe 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,24 +62,6 @@ describe('cluster checkup API', () => { }); }); - describe('with APM enabled', () => { - it('is provided to getUpgradeAssistantStatus', async () => { - const spy = jest.spyOn(MigrationApis, 'getUpgradeAssistantStatus'); - await routeDependencies.router.getHandler({ - method: 'get', - pathPattern: '/api/upgrade_assistant/status', - })(routeHandlerContextMock, createRequestMock(), kibanaResponseFactory); - - MigrationApis.getUpgradeAssistantStatus.mockResolvedValue({ - cluster: [], - indices: [], - nodes: [], - }); - - 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 c560bbd86cc4e6..be8d1739341825 100644 --- a/x-pack/plugins/upgrade_assistant/server/routes/cluster_checkup.ts +++ b/x-pack/plugins/upgrade_assistant/server/routes/cluster_checkup.ts @@ -5,21 +5,13 @@ * 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'; -export function registerClusterCheckupRoutes({ - cloud, - router, - apmOSS, - licensing, - log, -}: RouteDependencies) { +export function registerClusterCheckupRoutes({ cloud, router, licensing, log }: RouteDependencies) { const isCloudEnabled = Boolean(cloud?.isCloudEnabled); router.get( @@ -39,10 +31,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/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 730e750a8ffb62..00000000000000 --- 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 081e959ff08e21..00000000000000 --- 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 d337b45392a19f..00000000000000 --- 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 }); - } - - return response.internalError({ body: e }); - } - } - ) - ); -} 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 85aeb5b438f78f..5e5f83d067cf44 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); 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 cf2acf4794af45..aa8e42803121ca 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'; @@ -45,7 +44,6 @@ interface CreateReindexWorker { credentialStore: CredentialStore; savedObjects: SavedObjectsClient; licensing: LicensingPluginSetup; - apmIndexPatterns: string[]; } export function createReindexWorker({ @@ -54,17 +52,9 @@ export function createReindexWorker({ credentialStore, savedObjects, licensing, - apmIndexPatterns, }: CreateReindexWorker) { const esClient = elasticsearchService.client; - return new ReindexWorker( - savedObjects, - credentialStore, - esClient, - logger, - licensing, - apmIndexPatterns - ); + return new ReindexWorker(savedObjects, credentialStore, esClient, logger, licensing); } const mapAnyErrorToKibanaHttpResponse = (e: any) => { @@ -84,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/plugins/upgrade_assistant/server/types.ts b/x-pack/plugins/upgrade_assistant/server/types.ts index ad450a3fdaf1c6..80c60e3f310bce 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 2f6bdd371ad0d3..220ae4d0f0160d 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" },