Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Upgrade Assistant] Remove ML/Watcher logic #113224

Merged
merged 13 commits into from
Oct 6, 2021
4 changes: 0 additions & 4 deletions x-pack/plugins/translations/translations/ja-JP.json
Original file line number Diff line number Diff line change
Expand Up @@ -25787,12 +25787,8 @@
"xpack.upgradeAssistant.checkupTab.reindexing.flyout.checklistStep.reindexingChecklist.cancelButton.cancellingLabel": "キャンセル中…",
"xpack.upgradeAssistant.checkupTab.reindexing.flyout.checklistStep.reindexingChecklist.cancelButton.errorLabel": "キャンセルできませんでした",
"xpack.upgradeAssistant.checkupTab.reindexing.flyout.checklistStep.reindexingChecklist.createIndexStepTitle": "新規インデックスを作成中",
"xpack.upgradeAssistant.checkupTab.reindexing.flyout.checklistStep.reindexingChecklist.pauseMlStepTitle": "機械学習ジョブを一時停止中",
"xpack.upgradeAssistant.checkupTab.reindexing.flyout.checklistStep.reindexingChecklist.readonlyStepTitle": "古いインデックスを読み込み専用に設定中",
"xpack.upgradeAssistant.checkupTab.reindexing.flyout.checklistStep.reindexingChecklist.reindexingDocumentsStepTitle": "ドキュメントを再インデックス中",
"xpack.upgradeAssistant.checkupTab.reindexing.flyout.checklistStep.reindexingChecklist.resumeMlStepTitle": "機械学習ジョブを再開中",
"xpack.upgradeAssistant.checkupTab.reindexing.flyout.checklistStep.reindexingChecklist.resumeWatcherStepTitle": "Watcher を再開中",
"xpack.upgradeAssistant.checkupTab.reindexing.flyout.checklistStep.reindexingChecklist.stopWatcherStepTitle": "Watcher を停止中",
"xpack.upgradeAssistant.checkupTab.reindexing.flyout.checklistStep.reindexingChecklistTitle": "プロセスを再インデックス中",
"xpack.upgradeAssistant.checkupTab.reindexing.flyout.indexClosedCallout.calloutDetails": "このインデックスは現在閉じています。アップグレードアシスタントが開き、再インデックスを実行してからインデックスを閉じます。 {reindexingMayTakeLongerEmph}。詳細については {docs} をご覧ください。",
"xpack.upgradeAssistant.checkupTab.reindexing.flyout.indexClosedCallout.calloutDetails.reindexingTakesLongerEmphasis": "再インデックスには通常よりも時間がかかることがあります",
Expand Down
4 changes: 0 additions & 4 deletions x-pack/plugins/translations/translations/zh-CN.json
Original file line number Diff line number Diff line change
Expand Up @@ -26221,12 +26221,8 @@
"xpack.upgradeAssistant.checkupTab.reindexing.flyout.checklistStep.reindexingChecklist.cancelButton.cancellingLabel": "正在取消……",
"xpack.upgradeAssistant.checkupTab.reindexing.flyout.checklistStep.reindexingChecklist.cancelButton.errorLabel": "无法取消",
"xpack.upgradeAssistant.checkupTab.reindexing.flyout.checklistStep.reindexingChecklist.createIndexStepTitle": "正在创建新索引",
"xpack.upgradeAssistant.checkupTab.reindexing.flyout.checklistStep.reindexingChecklist.pauseMlStepTitle": "正在暂停 Machine Learning 作业",
"xpack.upgradeAssistant.checkupTab.reindexing.flyout.checklistStep.reindexingChecklist.readonlyStepTitle": "正在将旧索引设置为只读",
"xpack.upgradeAssistant.checkupTab.reindexing.flyout.checklistStep.reindexingChecklist.reindexingDocumentsStepTitle": "正在重新索引文档",
"xpack.upgradeAssistant.checkupTab.reindexing.flyout.checklistStep.reindexingChecklist.resumeMlStepTitle": "正在恢复 Machine Learning 作业",
"xpack.upgradeAssistant.checkupTab.reindexing.flyout.checklistStep.reindexingChecklist.resumeWatcherStepTitle": "正在恢复 Watcher",
"xpack.upgradeAssistant.checkupTab.reindexing.flyout.checklistStep.reindexingChecklist.stopWatcherStepTitle": "正在停止 Watcher",
"xpack.upgradeAssistant.checkupTab.reindexing.flyout.checklistStep.reindexingChecklistTitle": "重新索引过程",
"xpack.upgradeAssistant.checkupTab.reindexing.flyout.indexClosedCallout.calloutDetails": "此索引当前已关闭。升级助手将打开索引,重新索引,然后关闭索引。{reindexingMayTakeLongerEmph}。请参阅文档{docs}以了解更多信息。",
"xpack.upgradeAssistant.checkupTab.reindexing.flyout.indexClosedCallout.calloutDetails.reindexingTakesLongerEmphasis": "重新索引可能比通常花费更多的时间",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,6 @@ describe('Reindex deprecation flyout', () => {
httpRequestsMockHelpers.setReindexStatusResponse({
reindexOp: null,
warnings: [],
indexGroup: null,
hasRequiredPrivileges: true,
});

Expand Down
7 changes: 0 additions & 7 deletions x-pack/plugins/upgrade_assistant/common/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,11 @@ export type DeprecationSource = 'Kibana' | 'Elasticsearch';
export enum ReindexStep {
// Enum values are spaced out by 10 to give us room to insert steps in between.
created = 0,
indexGroupServicesStopped = 10,
readonly = 20,
newIndexCreated = 30,
reindexStarted = 40,
reindexCompleted = 50,
aliasCreated = 60,
indexGroupServicesStarted = 70,
}

export enum ReindexStatus {
Expand Down Expand Up @@ -117,11 +115,6 @@ export interface ReindexWarning {
};
}

export enum IndexGroup {
ml = '___ML_REINDEX_LOCK___',
watcher = '___WATCHER_REINDEX_LOCK___',
}

// Telemetry types
export const UPGRADE_ASSISTANT_TYPE = 'upgrade-assistant-telemetry';
export const UPGRADE_ASSISTANT_DOC_ID = 'upgrade-assistant-telemetry';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
import { shallow } from 'enzyme';
import React from 'react';

import { IndexGroup, ReindexStatus, ReindexStep } from '../../../../../../../common/types';
import { ReindexStatus, ReindexStep } from '../../../../../../../common/types';
import type { ReindexState } from '../use_reindex_state';
import { ReindexProgress } from './progress';

Expand All @@ -33,7 +33,7 @@ describe('ReindexProgress', () => {
steps={
Array [
Object {
"status": "incomplete",
sabarasaba marked this conversation as resolved.
Show resolved Hide resolved
"status": "inProgress",
"title": <FormattedMessage
defaultMessage="Setting old index to read-only"
id="xpack.upgradeAssistant.checkupTab.reindexing.flyout.checklistStep.reindexingChecklist.readonlyStepTitle"
Expand Down Expand Up @@ -118,7 +118,6 @@ describe('ReindexProgress', () => {
{
lastCompletedStep: ReindexStep.created,
status: ReindexStatus.inProgress,
indexGroup: IndexGroup.ml,
sabarasaba marked this conversation as resolved.
Show resolved Hide resolved
reindexTaskPercComplete: null,
errorMessage: null,
} as ReindexState
Expand All @@ -133,14 +132,6 @@ describe('ReindexProgress', () => {
Array [
Object {
"status": "inProgress",
"title": <FormattedMessage
defaultMessage="Pausing Machine Learning jobs"
id="xpack.upgradeAssistant.checkupTab.reindexing.flyout.checklistStep.reindexingChecklist.pauseMlStepTitle"
values={Object {}}
/>,
},
Object {
"status": "incomplete",
"title": <FormattedMessage
defaultMessage="Setting old index to read-only"
id="xpack.upgradeAssistant.checkupTab.reindexing.flyout.checklistStep.reindexingChecklist.readonlyStepTitle"
Expand Down Expand Up @@ -171,14 +162,6 @@ describe('ReindexProgress', () => {
values={Object {}}
/>,
},
Object {
"status": "incomplete",
"title": <FormattedMessage
defaultMessage="Resuming Machine Learning jobs"
id="xpack.upgradeAssistant.checkupTab.reindexing.flyout.checklistStep.reindexingChecklist.resumeMlStepTitle"
values={Object {}}
/>,
},
]
}
/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import {
} from '@elastic/eui';
import { FormattedMessage } from '@kbn/i18n/react';

import { IndexGroup, ReindexStatus, ReindexStep } from '../../../../../../../common/types';
import { ReindexStatus, ReindexStep } from '../../../../../../../common/types';
import { LoadingState } from '../../../../types';
import type { ReindexState } from '../use_reindex_state';
import { StepProgress, StepProgressStep } from './step_progress';
Expand Down Expand Up @@ -118,7 +118,7 @@ export const ReindexProgress: React.FunctionComponent<{
reindexState: ReindexState;
cancelReindex: () => void;
}> = (props) => {
const { errorMessage, indexGroup, lastCompletedStep = -1, status } = props.reindexState;
const { errorMessage, lastCompletedStep = -1, status } = props.reindexState;
const stepDetails = (thisStep: ReindexStep): Pick<StepProgressStep, 'status' | 'children'> => {
const previousStep = orderedSteps[orderedSteps.indexOf(thisStep) - 1];

Expand Down Expand Up @@ -225,46 +225,5 @@ export const ReindexProgress: React.FunctionComponent<{
},
];

// If this index is part of an index group, add the approriate group services steps.
if (indexGroup === IndexGroup.ml) {
steps.unshift({
title: (
<FormattedMessage
id="xpack.upgradeAssistant.checkupTab.reindexing.flyout.checklistStep.reindexingChecklist.pauseMlStepTitle"
defaultMessage="Pausing Machine Learning jobs"
/>
),
...stepDetails(ReindexStep.indexGroupServicesStopped),
});
steps.push({
title: (
<FormattedMessage
id="xpack.upgradeAssistant.checkupTab.reindexing.flyout.checklistStep.reindexingChecklist.resumeMlStepTitle"
defaultMessage="Resuming Machine Learning jobs"
/>
),
...stepDetails(ReindexStep.indexGroupServicesStarted),
});
} else if (indexGroup === IndexGroup.watcher) {
steps.unshift({
title: (
<FormattedMessage
id="xpack.upgradeAssistant.checkupTab.reindexing.flyout.checklistStep.reindexingChecklist.stopWatcherStepTitle"
defaultMessage="Stopping Watcher"
/>
),
...stepDetails(ReindexStep.indexGroupServicesStopped),
});
steps.push({
title: (
<FormattedMessage
id="xpack.upgradeAssistant.checkupTab.reindexing.flyout.checklistStep.reindexingChecklist.resumeWatcherStepTitle"
defaultMessage="Resuming Watcher"
/>
),
...stepDetails(ReindexStep.indexGroupServicesStarted),
});
}

return <StepProgress steps={steps} />;
};
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
import { useRef, useCallback, useState, useEffect } from 'react';

import {
IndexGroup,
ReindexOperation,
ReindexStatus,
ReindexStep,
Expand All @@ -28,19 +27,17 @@ export interface ReindexState {
errorMessage: string | null;
reindexWarnings?: ReindexWarning[];
hasRequiredPrivileges?: boolean;
indexGroup?: IndexGroup;
}

interface StatusResponse {
warnings?: ReindexWarning[];
reindexOp?: ReindexOperation;
hasRequiredPrivileges?: boolean;
indexGroup?: IndexGroup;
}

const getReindexState = (
reindexState: ReindexState,
{ reindexOp, warnings, hasRequiredPrivileges, indexGroup }: StatusResponse
{ reindexOp, warnings, hasRequiredPrivileges }: StatusResponse
) => {
const newReindexState = {
...reindexState,
Expand All @@ -55,10 +52,6 @@ const getReindexState = (
newReindexState.hasRequiredPrivileges = hasRequiredPrivileges;
}

if (indexGroup) {
newReindexState.indexGroup = indexGroup;
}

if (reindexOp) {
// Prevent the UI flickering back to inProgress after cancelling
newReindexState.lastCompletedStep = reindexOp.lastCompletedStep;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ import { ScopedClusterClientMock } from 'src/core/server/elasticsearch/client/mo
import moment from 'moment';

import {
IndexGroup,
REINDEX_OP_TYPE,
ReindexSavedObject,
ReindexStatus,
Expand Down Expand Up @@ -283,46 +282,4 @@ describe('ReindexActions', () => {
await expect(actions.getFlatSettings('myIndex')).resolves.toBeNull();
});
});

describe('runWhileConsumerLocked', () => {
Object.entries(IndexGroup).forEach(([typeKey, consumerType]) => {
describe(`IndexConsumerType.${typeKey}`, () => {
it('creates the lock doc if it does not exist and executes callback', async () => {
expect.assertions(3);
client.get.mockRejectedValueOnce(SavedObjectsErrorHelpers.createGenericNotFoundError()); // mock no ML doc exists yet
client.create.mockImplementationOnce((type: any, attributes: any, { id }: any) =>
Promise.resolve({
type,
id,
attributes,
})
);

let flip = false;
await actions.runWhileIndexGroupLocked(consumerType, async (mlDoc) => {
expect(mlDoc.id).toEqual(consumerType);
expect(mlDoc.attributes.runningReindexCount).toEqual(0);
flip = true;
return mlDoc;
});
expect(flip).toEqual(true);
});

it('fails after 10 attempts to lock', async () => {
client.get.mockResolvedValue({
type: REINDEX_OP_TYPE,
id: consumerType,
attributes: { mlReindexCount: 0 },
});

client.update.mockRejectedValue(new Error('NO LOCKING!'));

await expect(
actions.runWhileIndexGroupLocked(consumerType, async (m) => m)
).rejects.toThrow('Could not acquire lock for ML jobs');
expect(client.update).toHaveBeenCalledTimes(10);
}, 20000);
});
});
});
});
Loading