[logstash] remove "upgrade" functionality now that .logstash is a system index (#87056)

Co-authored-by: spalger <spalger@users.noreply.github.com>
This commit is contained in:
Spencer 2020-12-31 12:16:33 -07:00 committed by GitHub
parent aecee92257
commit 1da5fcf444
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
21 changed files with 1 additions and 1599 deletions

View file

@ -1,32 +0,0 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`UpgradeFailureActions component renders component as expected 1`] = `
<EuiFlexGroup
justifyContent="flexStart"
>
<EuiFlexItem
grow={false}
>
<EuiButton
fill={true}
onClick={[MockFunction]}
>
upgrade button text
</EuiButton>
</EuiFlexItem>
<EuiFlexItem
grow={false}
>
<EuiButtonEmpty
color="primary"
onClick={[MockFunction]}
>
<FormattedMessage
defaultMessage="Go back"
id="xpack.logstash.upgradeFailureActions.goBackButtonLabel"
values={Object {}}
/>
</EuiButtonEmpty>
</EuiFlexItem>
</EuiFlexGroup>
`;

View file

@ -1,23 +0,0 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`UpgradeFailureTitle component renders component as expected 1`] = `
<EuiFlexGroup>
<EuiFlexItem
grow={false}
>
<EuiIcon
size="xl"
type="alert"
/>
</EuiFlexItem>
<EuiFlexItem
grow={false}
>
<EuiTitle>
<h2>
the Title
</h2>
</EuiTitle>
</EuiFlexItem>
</EuiFlexGroup>
`;

View file

@ -1,34 +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;
* you may not use this file except in compliance with the Elastic License.
*/
import { i18n } from '@kbn/i18n';
export const UPGRADE_FAILURE = {
TITLE: {
IS_MANUAL_UPGRADE: i18n.translate('xpack.logstash.upgradeFailedTitle', {
defaultMessage: 'Upgrade failed',
}),
NOT_MANUAL_UPGRADE: i18n.translate('xpack.logstash.notManualUpgradeTitle', {
defaultMessage: 'Time for an upgrade!',
}),
},
MESSAGE: {
IS_NEW_PIPELINE: i18n.translate('xpack.logstash.newPipelineMessage', {
defaultMessage: 'Before you can add a pipeline, we need to upgrade your configuration.',
}),
NOT_NEW_PIPELINE: i18n.translate('xpack.logstash.notNewPipelineMessage', {
defaultMessage: 'Before you can edit this pipeline, we need to upgrade your configuration.',
}),
},
UPGRADE_BUTTON_TEXT: {
IS_MANUAL_UPGRADE: i18n.translate('xpack.logstash.manualUpgradeButtonLabel', {
defaultMessage: 'Try again',
}),
NOT_MANUAL_UPGRADE: i18n.translate('xpack.logstash.notManualUpgradeButtonLabel', {
defaultMessage: 'Upgrade',
}),
},
};

View file

@ -1,7 +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;
* you may not use this file except in compliance with the Elastic License.
*/
export { UpgradeFailure } from './upgrade_failure';

View file

@ -1,43 +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;
* you may not use this file except in compliance with the Elastic License.
*/
import React from 'react';
import { EuiEmptyPrompt, EuiPageContent } from '@elastic/eui';
import { UpgradeFailureTitle } from './upgrade_failure_title';
import { UpgradeFailureActions } from './upgrade_failure_actions';
import { UPGRADE_FAILURE } from './constants';
export function UpgradeFailure({ isNewPipeline, isManualUpgrade, onClose, onRetry }) {
const titleText = isManualUpgrade
? UPGRADE_FAILURE.TITLE.IS_MANUAL_UPGRADE
: UPGRADE_FAILURE.TITLE.NOT_MANUAL_UPGRADE;
const messageText = isNewPipeline
? UPGRADE_FAILURE.MESSAGE.IS_NEW_PIPELINE
: UPGRADE_FAILURE.MESSAGE.NOT_NEW_PIPELINE;
const upgradeButtonText = isManualUpgrade
? UPGRADE_FAILURE.UPGRADE_BUTTON_TEXT.IS_MANUAL_UPGRADE
: UPGRADE_FAILURE.UPGRADE_BUTTON_TEXT.NOT_MANUAL_UPGRADE;
return (
<div data-test-subj="pipelineEdit upgradeFailure" style={{ minHeight: '100vh' }}>
<EuiPageContent>
<EuiEmptyPrompt
actions={
<UpgradeFailureActions
onClose={onClose}
onRetry={onRetry}
upgradeButtonText={upgradeButtonText}
/>
}
title={<UpgradeFailureTitle titleText={titleText} />}
body={<p style={{ textAlign: 'left' }}>{messageText}</p>}
/>
</EuiPageContent>
</div>
);
}

View file

@ -1,55 +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;
* you may not use this file except in compliance with the Elastic License.
*/
import React from 'react';
import { shallowWithIntl, mountWithIntl } from '@kbn/test/jest';
import { UpgradeFailure } from './upgrade_failure';
describe('UpgradeFailure component', () => {
let props;
let onClose;
let onRetry;
beforeEach(() => {
onClose = jest.fn();
onRetry = jest.fn();
props = {
isManualUpgrade: true,
isNewPipeline: true,
onClose,
onRetry,
};
});
it('renders component as expected', () => {
const wrapper = shallowWithIntl(<UpgradeFailure {...props} />);
expect(wrapper).toMatchSnapshot();
});
it('passes expected text for new pipeline', () => {
const wrapper = mountWithIntl(<UpgradeFailure {...props} />);
expect(wrapper).toMatchSnapshot();
});
it('passes expected text for not new pipeline', () => {
props.isNewPipeline = false;
const wrapper = mountWithIntl(<UpgradeFailure {...props} />);
expect(wrapper).toMatchSnapshot();
});
it('passes expected text for not manual upgrade', () => {
props.isManualUpgrade = false;
const wrapper = mountWithIntl(<UpgradeFailure {...props} />);
expect(wrapper).toMatchSnapshot();
});
it('propogates onClose and onRetry functions to child', () => {
const wrapper = mountWithIntl(<UpgradeFailure {...props} />);
expect(wrapper.find('UpgradeFailureActions').props().onClose).toEqual(onClose);
expect(wrapper.find('UpgradeFailureActions').props().onRetry).toEqual(onRetry);
});
});

View file

@ -1,36 +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;
* you may not use this file except in compliance with the Elastic License.
*/
import React from 'react';
import PropTypes from 'prop-types';
import { EuiButton, EuiButtonEmpty, EuiFlexGroup, EuiFlexItem } from '@elastic/eui';
import { FormattedMessage } from '@kbn/i18n/react';
export function UpgradeFailureActions({ onClose, onRetry, upgradeButtonText }) {
return (
<EuiFlexGroup justifyContent="flexStart">
<EuiFlexItem grow={false}>
<EuiButton fill onClick={onRetry}>
{upgradeButtonText}
</EuiButton>
</EuiFlexItem>
<EuiFlexItem grow={false}>
<EuiButtonEmpty color="primary" onClick={onClose}>
<FormattedMessage
id="xpack.logstash.upgradeFailureActions.goBackButtonLabel"
defaultMessage="Go back"
/>
</EuiButtonEmpty>
</EuiFlexItem>
</EuiFlexGroup>
);
}
UpgradeFailureActions.propTypes = {
onClose: PropTypes.func.isRequired,
onRetry: PropTypes.func.isRequired,
upgradeButtonText: PropTypes.string.isRequired,
};

View file

@ -1,42 +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;
* you may not use this file except in compliance with the Elastic License.
*/
import React from 'react';
import { shallowWithIntl, mountWithIntl } from '@kbn/test/jest';
import { UpgradeFailureActions } from './upgrade_failure_actions';
describe('UpgradeFailureActions component', () => {
let props;
let onClose;
let onRetry;
beforeEach(() => {
onClose = jest.fn();
onRetry = jest.fn();
props = {
onClose,
onRetry,
upgradeButtonText: 'upgrade button text',
};
});
it('renders component as expected', () => {
const wrapper = shallowWithIntl(<UpgradeFailureActions {...props} />);
expect(wrapper).toMatchSnapshot();
});
it('calls onRetry on update click', () => {
const wrapper = mountWithIntl(<UpgradeFailureActions {...props} />);
wrapper.find('EuiButton').simulate('click');
expect(onRetry).toHaveBeenCalledTimes(1);
});
it('calls onClose on "Go back" click', () => {
const wrapper = mountWithIntl(<UpgradeFailureActions {...props} />);
wrapper.find('EuiButtonEmpty').simulate('click');
expect(onClose).toHaveBeenCalledTimes(1);
});
});

View file

@ -1,28 +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;
* you may not use this file except in compliance with the Elastic License.
*/
import React from 'react';
import PropTypes from 'prop-types';
import { EuiFlexGroup, EuiFlexItem, EuiIcon, EuiTitle } from '@elastic/eui';
export function UpgradeFailureTitle({ titleText }) {
return (
<EuiFlexGroup>
<EuiFlexItem grow={false}>
<EuiIcon size="xl" type="alert" />
</EuiFlexItem>
<EuiFlexItem grow={false}>
<EuiTitle>
<h2>{titleText}</h2>
</EuiTitle>
</EuiFlexItem>
</EuiFlexGroup>
);
}
UpgradeFailureTitle.propTypes = {
titleText: PropTypes.string.isRequired,
};

View file

@ -1,21 +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;
* you may not use this file except in compliance with the Elastic License.
*/
import React from 'react';
import { shallow } from 'enzyme';
import { UpgradeFailureTitle } from './upgrade_failure_title';
describe('UpgradeFailureTitle component', () => {
let props;
beforeEach(() => {
props = { titleText: 'the Title' };
});
it('renders component as expected', () => {
const wrapper = shallow(<UpgradeFailureTitle {...props} />);
expect(wrapper).toMatchSnapshot();
});
});

View file

@ -17,7 +17,6 @@ import {
MonitoringService,
PipelineService,
PipelinesService,
UpgradeService,
// @ts-ignore
} from '../services';
// @ts-ignore
@ -39,7 +38,6 @@ export const renderApp = async (
const monitoringService = new MonitoringService(core.http, isMonitoringEnabled, clusterService);
const pipelinesService = new PipelinesService(core.http, monitoringService);
const pipelineService = new PipelineService(core.http, pipelinesService);
const upgradeService = new UpgradeService(core.http);
ReactDOM.render(
<core.i18n.Context>
@ -77,7 +75,6 @@ export const renderApp = async (
logstashLicenseService={logstashLicenseService}
pipelineService={pipelineService}
toasts={core.notifications.toasts}
upgradeService={upgradeService}
/>
)}
/>
@ -96,7 +93,6 @@ export const renderApp = async (
logstashLicenseService={logstashLicenseService}
pipelineService={pipelineService}
toasts={core.notifications.toasts}
upgradeService={upgradeService}
id={match.params.id}
/>
)}

View file

@ -11,8 +11,6 @@ import { History } from 'history';
import { i18n } from '@kbn/i18n';
import { ToastsStart } from 'src/core/public';
// @ts-ignore
import { UpgradeFailure } from './components/upgrade_failure';
// @ts-ignore
import { PipelineEditor } from './components/pipeline_editor';
// @ts-ignore
@ -59,23 +57,9 @@ const usePipeline = (
return pipeline;
};
const useIsUpgraded = (upgradeService: any) => {
const [isUpgraded, setIsUpgraded] = useState<null | boolean>(null);
const mounted = usePromise();
useLayoutEffect(() => {
mounted(upgradeService.executeUpgrade() as Promise<boolean>).then((result) =>
setIsUpgraded(result)
);
}, [mounted, upgradeService]);
return isUpgraded;
};
interface EditProps {
pipelineService: any;
logstashLicenseService: any;
upgradeService: any;
toasts: ToastsStart;
history: History;
setBreadcrumbs: ManagementAppMountParams['setBreadcrumbs'];
@ -87,24 +71,16 @@ interface EditProps {
export const PipelineEditView: React.FC<EditProps> = ({
pipelineService,
logstashLicenseService,
upgradeService,
toasts,
history,
setBreadcrumbs,
id,
}) => {
const params = new URLSearchParams(history.location.search);
const shouldRetry = params.get('retry') === 'true';
const shouldClone = params.get('clone') === '';
const pipeline = usePipeline(pipelineService, logstashLicenseService, toasts, shouldClone, id);
const isUpgraded = useIsUpgraded(upgradeService);
const onRetry = useCallback(() => {
const newParams = new URLSearchParams(history.location.search);
newParams.set('retry', 'true');
history.replace({ search: newParams.toString() });
}, [history]);
const close = useCallback(() => {
history.push('/');
}, [history]);
@ -115,7 +91,7 @@ export const PipelineEditView: React.FC<EditProps> = ({
[history]
);
if (!pipeline || isUpgraded === null) {
if (!pipeline) {
return null;
}
@ -126,17 +102,6 @@ export const PipelineEditView: React.FC<EditProps> = ({
: Breadcrumbs.getPipelineEditBreadcrumbs(pipeline.id)
);
if (!isUpgraded) {
return (
<UpgradeFailure
isNewPipeline={isNewPipeline}
isManualUpgrade={!!shouldRetry}
onRetry={onRetry}
onClose={close}
/>
);
}
return (
<PipelineEditor
id={id}

View file

@ -9,4 +9,3 @@ export { LogstashLicenseService } from './license';
export { MonitoringService } from './monitoring';
export { PipelineService } from './pipeline';
export { PipelinesService } from './pipelines';
export { UpgradeService } from './upgrade';

View file

@ -1,7 +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;
* you may not use this file except in compliance with the Elastic License.
*/
export { UpgradeService } from './upgrade_service';

View file

@ -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;
* you may not use this file except in compliance with the Elastic License.
*/
import { ROUTES } from '../../../common/constants';
export class UpgradeService {
constructor(http) {
this.http = http;
}
executeUpgrade() {
return this.http
.post(`${ROUTES.API_ROOT}/upgrade`)
.then((response) => response.is_upgraded)
.catch((e) => {
throw e.message;
});
}
}

View file

@ -12,7 +12,6 @@ import {
registerPipelineSaveRoute,
} from './pipeline';
import { registerPipelinesListRoute, registerPipelinesDeleteRoute } from './pipelines';
import { registerUpgradeRoute } from './upgrade';
export function registerRoutes(router: IRouter, security?: SecurityPluginSetup) {
registerClusterLoadRoute(router);
@ -23,6 +22,4 @@ export function registerRoutes(router: IRouter, security?: SecurityPluginSetup)
registerPipelinesListRoute(router);
registerPipelinesDeleteRoute(router);
registerUpgradeRoute(router);
}

View file

@ -1,7 +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;
* you may not use this file except in compliance with the Elastic License.
*/
export { registerUpgradeRoute } from './upgrade';

View file

@ -1,46 +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;
* you may not use this file except in compliance with the Elastic License.
*/
import { IRouter } from 'src/core/server';
import { wrapRouteWithLicenseCheck } from '../../../../licensing/server';
import { INDEX_NAMES } from '../../../common/constants';
import { checkLicense } from '../../lib/check_license';
export function registerUpgradeRoute(router: IRouter) {
router.post(
{
path: '/api/logstash/upgrade',
validate: false,
},
wrapRouteWithLicenseCheck(
checkLicense,
router.handleLegacyErrors(async (context, request, response) => {
const client = context.logstash!.esClient;
const doesIndexExist = await client.callAsCurrentUser('indices.exists', {
index: INDEX_NAMES.PIPELINES,
});
// If index doesn't exist yet, there is no mapping to upgrade
if (doesIndexExist) {
await client.callAsCurrentUser('indices.putMapping', {
index: INDEX_NAMES.PIPELINES,
body: {
properties: {
pipeline_settings: {
dynamic: false,
type: 'object',
},
},
},
});
}
return response.ok({ body: { is_upgraded: true } });
})
)
);
}

View file

@ -10907,11 +10907,6 @@
"xpack.logstash.managementSection.notPossibleToManagePipelinesMessage": "現在ライセンス情報が利用できないため Logstash パイプラインを使用できません。",
"xpack.logstash.managementSection.pipelineCrudOperationsNotAllowedDescription": "ご使用の {licenseType} ライセンスは期限切れのため、Logstash パイプラインの編集、作成、削除ができません。",
"xpack.logstash.managementSection.pipelinesTitle": "Logstashパイプライン",
"xpack.logstash.manualUpgradeButtonLabel": "再試行",
"xpack.logstash.newPipelineMessage": "パイプラインを追加する前に、構成をアップグレードする必要があります。",
"xpack.logstash.notManualUpgradeButtonLabel": "アップグレード",
"xpack.logstash.notManualUpgradeTitle": "アップグレードの時がやってきました!",
"xpack.logstash.notNewPipelineMessage": "このパイプラインを編集する前に、構成をアップグレードする必要があります。",
"xpack.logstash.pipelineBatchDelayTooltip": "パイプラインイベントバッチを作成する際、それぞれのイベントでパイプラインワーカーにサイズの小さなバッチを送る前に何ミリ秒間待つかです。\n\nデフォルト値:50ms",
"xpack.logstash.pipelineBatchSizeTooltip": "フィルターとアウトプットをを実行する前に各ワーカースレッドがインプットから収集するイベントの最低数です。基本的にバッチサイズが大きくなるほど効率が上がりますが、メモリーオーバーヘッドも大きくなります。このオプションを効率的に使用するには、LS_HEAP_SIZE 変数を設定して JVM のヒープサイズを増やす必要があるかもしれません。\n\nデフォルト値:125",
"xpack.logstash.pipelineEditor.cancelButtonLabel": "キャンセル",
@ -10970,8 +10965,6 @@
"xpack.logstash.units.megabytesLabel": "メガバイト",
"xpack.logstash.units.petabytesLabel": "ペタバイト",
"xpack.logstash.units.terabytesLabel": "テラバイト",
"xpack.logstash.upgradeFailedTitle": "アップグレード失敗",
"xpack.logstash.upgradeFailureActions.goBackButtonLabel": "戻る",
"xpack.logstash.upstreamPipelineArgumentMustContainAnIdPropertyErrorMessage": "upstreamPipeline 引数には id プロパティを含める必要があります",
"xpack.logstash.workersTooltip": "パイプラインのフィルターとアウトプットステージを同時に実行するワーカーの数です。イベントが詰まってしまう場合や CPU が飽和状態ではない場合は、マシンの処理能力をより有効に活用するため、この数字を上げてみてください。\n\nデフォルト値:ホストの CPU コア数です",
"xpack.maps.actionSelect.label": "アクション",

View file

@ -10920,11 +10920,6 @@
"xpack.logstash.managementSection.notPossibleToManagePipelinesMessage": "您不能管理 Logstash 管道,因为许可信息当前不可用。",
"xpack.logstash.managementSection.pipelineCrudOperationsNotAllowedDescription": "您不能编辑、创建或删除您的 Logstash 管道,因为您的{licenseType}许可已过期。",
"xpack.logstash.managementSection.pipelinesTitle": "Logstash 管道",
"xpack.logstash.manualUpgradeButtonLabel": "重试",
"xpack.logstash.newPipelineMessage": "在您可以添加管道之前,我们需要升级您的配置。",
"xpack.logstash.notManualUpgradeButtonLabel": "升级",
"xpack.logstash.notManualUpgradeTitle": "是时候升级了!",
"xpack.logstash.notNewPipelineMessage": "在您可以编辑此管道之前,我们需要升级您的配置。",
"xpack.logstash.pipelineBatchDelayTooltip": "创建管道事件批时,将过小的批分派给管道工作线程之前要等候每个事件的时长(毫秒)。\n\n默认值50ms",
"xpack.logstash.pipelineBatchSizeTooltip": "单个工作线程在尝试执行其筛选和输出之前可以从输入收集的最大事件数目。较大的批大小通常更有效,但代价是内存开销也较大。您可能需要通过设置 LS_HEAP_SIZE 变量来增大 JVM 堆大小,从而有效利用该选项。\n\n默认值125",
"xpack.logstash.pipelineEditor.cancelButtonLabel": "取消",
@ -10983,8 +10978,6 @@
"xpack.logstash.units.megabytesLabel": "兆字节",
"xpack.logstash.units.petabytesLabel": "万兆字节",
"xpack.logstash.units.terabytesLabel": "兆兆字节",
"xpack.logstash.upgradeFailedTitle": "升级失败",
"xpack.logstash.upgradeFailureActions.goBackButtonLabel": "返回",
"xpack.logstash.upstreamPipelineArgumentMustContainAnIdPropertyErrorMessage": "upstreamPipeline 参数必须包含 id 属性",
"xpack.logstash.workersTooltip": "并行执行管道的筛选和输出阶段的工作线程数目。如果您发现事件出现积压或 CPU 未饱和,请考虑增大此数值,以更好地利用机器处理能力。\n\n默认值主机的 CPU 核心数",
"xpack.maps.actionSelect.label": "操作",