Skip to content

Commit

Permalink
[Index Management] Remove freeze index action and api (#116110)
Browse files Browse the repository at this point in the history
* Remove freeze index action and api

* Remove unused translations

* Add test for unfreeze action

* Fix tests

* Fix tests
  • Loading branch information
sabarasaba authored Oct 26, 2021
1 parent d91bd98 commit 3920918
Show file tree
Hide file tree
Showing 17 changed files with 33 additions and 218 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -59,4 +59,5 @@ export type TestSubjects =
| 'templatesTab'
| 'templateTable'
| 'title'
| 'unfreezeIndexMenuButton'
| 'viewButton';
Original file line number Diff line number Diff line change
Expand Up @@ -159,9 +159,15 @@ describe('<IndexManagementHome />', () => {

describe('index actions', () => {
const indexName = 'testIndex';
const indexMock = createNonDataStreamIndex(indexName);

beforeEach(async () => {
httpRequestsMockHelpers.setLoadIndicesResponse([createNonDataStreamIndex(indexName)]);
httpRequestsMockHelpers.setLoadIndicesResponse([
{
...indexMock,
isFrozen: true,
},
]);
httpRequestsMockHelpers.setReloadIndicesResponse({ indexNames: [indexName] });

testBed = await setup();
Expand All @@ -183,5 +189,27 @@ describe('<IndexManagementHome />', () => {
// a reload server call also.
expect(server.requests[requestsCount - 1].url).toBe(`${API_BASE_PATH}/indices/reload`);
});

test('should be able to unfreeze a frozen index', async () => {
const { actions, exists } = testBed;

httpRequestsMockHelpers.setReloadIndicesResponse([{ ...indexMock, isFrozen: false }]);

// Open context menu
await actions.clickManageContextMenuButton();
// Check that the unfreeze action exists for the current index and unfreeze it
expect(exists('unfreezeIndexMenuButton')).toBe(true);
await actions.clickContextMenuOption('unfreezeIndexMenuButton');

const requestsCount = server.requests.length;
expect(server.requests[requestsCount - 2].url).toBe(`${API_BASE_PATH}/indices/unfreeze`);
// After the index is unfrozen, we imediately do a reload. So we need to expect to see
// a reload server call also.
expect(server.requests[requestsCount - 1].url).toBe(`${API_BASE_PATH}/indices/reload`);
// Open context menu once again, since clicking an action will close it.
await actions.clickManageContextMenuButton();
// The unfreeze action should not be present anymore
expect(exists('unfreezeIndexMenuButton')).toBe(false);
});
});
});

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 0 additions & 2 deletions x-pack/plugins/index_management/common/constants/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,6 @@ export {
UIM_INDEX_FLUSH_MANY,
UIM_INDEX_FORCE_MERGE,
UIM_INDEX_FORCE_MERGE_MANY,
UIM_INDEX_FREEZE,
UIM_INDEX_FREEZE_MANY,
UIM_INDEX_OPEN,
UIM_INDEX_OPEN_MANY,
UIM_INDEX_REFRESH,
Expand Down
2 changes: 0 additions & 2 deletions x-pack/plugins/index_management/common/constants/ui_metric.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,6 @@ export const UIM_INDEX_FLUSH = 'index_flush';
export const UIM_INDEX_FLUSH_MANY = 'index_flush_many';
export const UIM_INDEX_FORCE_MERGE = 'index_force_merge';
export const UIM_INDEX_FORCE_MERGE_MANY = 'index_force_merge_many';
export const UIM_INDEX_FREEZE = 'index_freeze';
export const UIM_INDEX_FREEZE_MANY = 'index_freeze_many';
export const UIM_INDEX_OPEN = 'index_open';
export const UIM_INDEX_OPEN_MANY = 'index_open_many';
export const UIM_INDEX_REFRESH = 'index_refresh';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ import {
openDetailPanel,
performExtensionAction,
reloadIndices,
freezeIndices,
unfreezeIndices,
} from '../../../../store/actions';

Expand Down Expand Up @@ -68,9 +67,6 @@ const mapDispatchToProps = (dispatch, { indexNames }) => {
refreshIndices: () => {
dispatch(refreshIndices({ indexNames }));
},
freezeIndices: () => {
dispatch(freezeIndices({ indexNames }));
},
unfreezeIndices: () => {
dispatch(unfreezeIndices({ indexNames }));
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,6 @@ export class IndexActionsContextMenu extends Component {
return indexStatusByName[indexName] === INDEX_OPEN;
});
const allFrozen = every(indices, (index) => index.isFrozen);
const allUnfrozen = every(indices, (index) => !index.isFrozen);
const selectedIndexCount = indexNames.length;
const items = [];
if (!detailPanel && selectedIndexCount === 1) {
Expand Down Expand Up @@ -178,6 +177,7 @@ export class IndexActionsContextMenu extends Component {
});
if (allFrozen) {
items.push({
'data-test-subj': 'unfreezeIndexMenuButton',
name: i18n.translate('xpack.idxMgmt.indexActionsMenu.unfreezeIndexLabel', {
defaultMessage: 'Unfreeze {selectedIndexCount, plural, one {index} other {indices} }',
values: { selectedIndexCount },
Expand All @@ -186,17 +186,6 @@ export class IndexActionsContextMenu extends Component {
this.closePopoverAndExecute(unfreezeIndices);
},
});
} else if (allUnfrozen) {
items.push({
name: i18n.translate('xpack.idxMgmt.indexActionsMenu.freezeIndexLabel', {
defaultMessage: 'Freeze {selectedIndexCount, plural, one {index} other {indices} }',
values: { selectedIndexCount },
}),
onClick: () => {
this.closePopover();
this.setState({ renderConfirmModal: this.renderConfirmFreezeModal });
},
});
}
} else {
items.push({
Expand Down Expand Up @@ -619,76 +608,6 @@ export class IndexActionsContextMenu extends Component {
);
};

renderConfirmFreezeModal = () => {
const { freezeIndices, indexNames } = this.props;

return (
<EuiConfirmModal
title={i18n.translate(
'xpack.idxMgmt.indexActionsMenu.freezeEntity.confirmModal.modalTitle',
{
defaultMessage: 'Confirm freeze {count, plural, one {index} other {indices}}',
values: {
count: indexNames.length,
},
}
)}
onCancel={this.closeConfirmModal}
onConfirm={() => this.closePopoverAndExecute(freezeIndices)}
cancelButtonText={i18n.translate(
'xpack.idxMgmt.indexActionsMenu.freezeEntity.confirmModal.cancelButtonText',
{
defaultMessage: 'Cancel',
}
)}
confirmButtonText={i18n.translate(
'xpack.idxMgmt.indexActionsMenu.freezeEntity.confirmModal.confirmButtonText',
{
defaultMessage: 'Freeze {count, plural, one {index} other {indices}}',
values: {
count: indexNames.length,
},
}
)}
>
<p>
<FormattedMessage
id="xpack.idxMgmt.indexActionsMenu.freezeEntity.freezeDescription"
defaultMessage="You are about to freeze {count, plural, one {this index} other {these indices}}:"
values={{ count: indexNames.length }}
/>
</p>

<ul>
{indexNames.map((indexName) => (
<li key={indexName}>{indexName}</li>
))}
</ul>

<EuiCallOut
title={i18n.translate(
'xpack.idxMgmt.indexActionsMenu.freezeEntity.proceedWithCautionCallOutTitle',
{
defaultMessage: 'Proceed with caution',
}
)}
color="warning"
iconType="help"
>
<p>
<FormattedMessage
id="xpack.idxMgmt.indexActionsMenu.freezeEntity.freezeEntityWarningDescription"
defaultMessage="
A frozen index has little overhead on the cluster and is blocked for write operations.
You can search a frozen index, but expect queries to be slower.
"
/>
</p>
</EuiCallOut>
</EuiConfirmModal>
);
};

render() {
return (
<AppContextConsumer>
Expand Down
12 changes: 0 additions & 12 deletions x-pack/plugins/index_management/public/application/services/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,6 @@ import {
UIM_INDEX_FLUSH_MANY,
UIM_INDEX_FORCE_MERGE,
UIM_INDEX_FORCE_MERGE_MANY,
UIM_INDEX_FREEZE,
UIM_INDEX_FREEZE_MANY,
UIM_INDEX_OPEN,
UIM_INDEX_OPEN_MANY,
UIM_INDEX_REFRESH,
Expand Down Expand Up @@ -177,16 +175,6 @@ export async function clearCacheIndices(indices: string[]) {
uiMetricService.trackMetric(METRIC_TYPE.COUNT, eventName);
return response;
}
export async function freezeIndices(indices: string[]) {
const body = JSON.stringify({
indices,
});
const response = await httpService.httpClient.post(`${API_BASE_PATH}/indices/freeze`, { body });
// Only track successful requests.
const eventName = indices.length > 1 ? UIM_INDEX_FREEZE_MANY : UIM_INDEX_FREEZE;
uiMetricService.trackMetric(METRIC_TYPE.COUNT, eventName);
return response;
}
export async function unfreezeIndices(indices: string[]) {
const body = JSON.stringify({
indices,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ export {
flushIndices,
forcemergeIndices,
clearCacheIndices,
freezeIndices,
unfreezeIndices,
loadIndexSettings,
updateIndexSettings,
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ export * from './load_indices';
export * from './load_index_data';
export * from './open_indices';
export * from './refresh_indices';
export * from './freeze_indices';
export * from './unfreeze_indices';
export * from './reload_indices';
export * from './table_state';
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ import { registerOpenRoute } from './register_open_route';
import { registerRefreshRoute } from './register_refresh_route';
import { registerReloadRoute } from './register_reload_route';
import { registerDeleteRoute } from './register_delete_route';
import { registerFreezeRoute } from './register_freeze_route';
import { registerUnfreezeRoute } from './register_unfreeze_route';

export function registerIndicesRoutes(dependencies: RouteDependencies) {
Expand All @@ -29,6 +28,5 @@ export function registerIndicesRoutes(dependencies: RouteDependencies) {
registerRefreshRoute(dependencies);
registerReloadRoute(dependencies);
registerDeleteRoute(dependencies);
registerFreezeRoute(dependencies);
registerUnfreezeRoute(dependencies);
}
5 changes: 0 additions & 5 deletions x-pack/plugins/translations/translations/ja-JP.json
Original file line number Diff line number Diff line change
Expand Up @@ -11640,7 +11640,6 @@
"xpack.idxMgmt.formWizard.stepSettings.settingsDescription": "インデックスの動作を定義します。",
"xpack.idxMgmt.formWizard.stepSettings.settingsEditorHelpText": "JSONフォーマットを使用:{code}",
"xpack.idxMgmt.formWizard.stepSettings.stepTitle": "インデックス設定(任意)",
"xpack.idxMgmt.freezeIndicesAction.successfullyFrozeIndicesMessage": "[{indexNames}] が凍結されました",
"xpack.idxMgmt.frozenBadgeLabel": "凍結",
"xpack.idxMgmt.home.appTitle": "インデックス管理",
"xpack.idxMgmt.home.componentTemplates.checkingPrivilegesDescription": "権限を確認中…",
Expand Down Expand Up @@ -11690,10 +11689,6 @@
"xpack.idxMgmt.indexActionsMenu.forceMerge.forceMergeWarningDescription": " まだ書き込み中のインデックスや、将来もう一度書き込む予定がある強制・マージしないでください。自動バックグラウンドマージプロセスを活用して、スムーズなインデックス実行に必要なマージを実行できます。強制・マージインデックスに書き込む場合、パフォーマンスが大幅に低下する可能性があります。",
"xpack.idxMgmt.indexActionsMenu.forceMerge.maximumNumberOfSegmentsFormRowLabel": "シャードごとの最大セグメント数",
"xpack.idxMgmt.indexActionsMenu.forceMerge.proceedWithCautionCallOutTitle": "十分ご注意ください!",
"xpack.idxMgmt.indexActionsMenu.freezeEntity.confirmModal.cancelButtonText": "キャンセル",
"xpack.idxMgmt.indexActionsMenu.freezeEntity.freezeDescription": "{count, plural, one {このインデックス} other {これらのインデックス} }を凍結しようとしています。",
"xpack.idxMgmt.indexActionsMenu.freezeEntity.freezeEntityWarningDescription": " 凍結されたインデックスはクラスターにほとんどオーバーヘッドがなく、書き込みオペレーションがブロックされます。凍結されたインデックスは検索できますが、クエリが遅くなります。",
"xpack.idxMgmt.indexActionsMenu.freezeEntity.proceedWithCautionCallOutTitle": "十分ご注意ください",
"xpack.idxMgmt.indexActionsMenu.segmentsNumberErrorMessage": "セグメント数は 0 より大きい値である必要があります。",
"xpack.idxMgmt.indexStatusLabels.clearingCacheStatusLabel": "キャッシュを消去中...",
"xpack.idxMgmt.indexStatusLabels.closedStatusLabel": "クローズ済み",
Expand Down
8 changes: 0 additions & 8 deletions x-pack/plugins/translations/translations/zh-CN.json
Original file line number Diff line number Diff line change
Expand Up @@ -11772,7 +11772,6 @@
"xpack.idxMgmt.formWizard.stepSettings.settingsDescription": "定义索引的行为。",
"xpack.idxMgmt.formWizard.stepSettings.settingsEditorHelpText": "使用 JSON 格式:{code}",
"xpack.idxMgmt.formWizard.stepSettings.stepTitle": "索引设置(可选)",
"xpack.idxMgmt.freezeIndicesAction.successfullyFrozeIndicesMessage": "成功冻结:[{indexNames}]",
"xpack.idxMgmt.frozenBadgeLabel": "已冻结",
"xpack.idxMgmt.home.appTitle": "索引管理",
"xpack.idxMgmt.home.componentTemplates.checkingPrivilegesDescription": "正在检查权限……",
Expand Down Expand Up @@ -11835,13 +11834,6 @@
"xpack.idxMgmt.indexActionsMenu.forceMerge.maximumNumberOfSegmentsFormRowLabel": "每分片最大段数",
"xpack.idxMgmt.indexActionsMenu.forceMerge.proceedWithCautionCallOutTitle": "谨慎操作!",
"xpack.idxMgmt.indexActionsMenu.forceMergeIndexLabel": "强制合并{selectedIndexCount, plural, other {索引} }",
"xpack.idxMgmt.indexActionsMenu.freezeEntity.confirmModal.cancelButtonText": "取消",
"xpack.idxMgmt.indexActionsMenu.freezeEntity.confirmModal.confirmButtonText": "隐藏{count, plural, other {索引}}",
"xpack.idxMgmt.indexActionsMenu.freezeEntity.confirmModal.modalTitle": "确认冻结{count, plural, other {索引}}",
"xpack.idxMgmt.indexActionsMenu.freezeEntity.freezeDescription": "您将要冻结{count, plural, other {以下索引}}:",
"xpack.idxMgmt.indexActionsMenu.freezeEntity.freezeEntityWarningDescription": " 冻结的索引在集群上有很少的开销,已被阻止进行写操作。您可以搜索冻结的索引,但查询应会较慢。",
"xpack.idxMgmt.indexActionsMenu.freezeEntity.proceedWithCautionCallOutTitle": "谨慎操作",
"xpack.idxMgmt.indexActionsMenu.freezeIndexLabel": "冻结{selectedIndexCount, plural, other {索引} }",
"xpack.idxMgmt.indexActionsMenu.manageButtonAriaLabel": "{selectedIndexCount, plural, other {索引} }选项",
"xpack.idxMgmt.indexActionsMenu.manageButtonLabel": "管理{selectedIndexCount, plural, one {索引} other { {selectedIndexCount} 个索引}}",
"xpack.idxMgmt.indexActionsMenu.openIndexLabel": "打开{selectedIndexCount, plural, other {索引} }",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,6 @@ export const registerHelpers = ({ supertest }) => {

const forceMerge = (index, args) => executeActionOnIndices(index, 'forcemerge', args);

const freeze = (index) => executeActionOnIndices(index, 'freeze');

const unfreeze = (index) => executeActionOnIndices(index, 'unfreeze');

const clearCache = (index) => executeActionOnIndices(index, 'clear_cache');
Expand All @@ -47,7 +45,6 @@ export const registerHelpers = ({ supertest }) => {
flushIndex,
refreshIndex,
forceMerge,
freeze,
unfreeze,
list,
reload,
Expand Down
Loading

0 comments on commit 3920918

Please sign in to comment.