Skip to content

Commit

Permalink
[UA] Handle frozen indices deprecations (#208156)
Browse files Browse the repository at this point in the history
## Summary

Closes elastic/kibana-team#1392

---------

Co-authored-by: kibanamachine <42973632+kibanamachine@users.noreply.github.com>
  • Loading branch information
gsoldevila and kibanamachine authored Jan 30, 2025
1 parent 6925d12 commit cc358e3
Show file tree
Hide file tree
Showing 11 changed files with 272 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -368,6 +368,7 @@ export const getDocLinks = ({ kibanaBranch, buildFlavor }: GetDocLinkOptions): D
overview: `${KIBANA_DOCS}upgrade-assistant.html`,
batchReindex: `${KIBANA_DOCS}batch-start-resume-reindex.html`,
remoteReindex: `${ELASTICSEARCH_DOCS}docs-reindex.html#reindex-from-remote`,
unfreezeApi: `${ELASTICSEARCH_DOCS}unfreeze-index-api.html`,
reindexWithPipeline: `${ELASTICSEARCH_DOCS}docs-reindex.html#reindex-with-an-ingest-pipeline`,
},
rollupJobs: `${KIBANA_DOCS}data-rollups.html`,
Expand Down
1 change: 1 addition & 0 deletions src/platform/packages/shared/kbn-doc-links/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -325,6 +325,7 @@ export interface DocLinks {
readonly overview: string;
readonly batchReindex: string;
readonly remoteReindex: string;
readonly unfreezeApi: string;
readonly reindexWithPipeline: string;
};
readonly rollupJobs: string;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -237,6 +237,7 @@ export interface EnrichedDeprecationInfo
| 'ilm_policies'
| 'templates';
isCritical: boolean;
frozen?: boolean;
status?: estypes.HealthReportIndicatorHealthStatus;
index?: string;
correctiveAction?:
Expand Down

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

Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ jest.mock('../../../../../app_context', () => {
describe('ChecklistFlyout', () => {
const defaultProps = {
indexName: 'myIndex',
frozen: false,
closeFlyout: jest.fn(),
confirmInputValue: 'CONFIRM',
onConfirmInputChange: jest.fn(),
Expand Down Expand Up @@ -67,6 +68,12 @@ describe('ChecklistFlyout', () => {
expect(shallow(<ChecklistFlyoutStep {...defaultProps} />)).toMatchSnapshot();
});

it('renders for frozen indices', () => {
const props = cloneDeep(defaultProps);
props.frozen = true;
expect(shallow(<ChecklistFlyoutStep {...props} />)).toMatchSnapshot();
});

it('disables button while reindexing', () => {
const props = cloneDeep(defaultProps);
props.reindexState.status = ReindexStatus.inProgress;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,11 +72,12 @@ const buttonLabel = (status?: ReindexStatus) => {
* Displays a flyout that shows the current reindexing status for a given index.
*/
export const ChecklistFlyoutStep: React.FunctionComponent<{
frozen?: boolean;
closeFlyout: () => void;
reindexState: ReindexState;
startReindex: () => void;
cancelReindex: () => void;
}> = ({ closeFlyout, reindexState, startReindex, cancelReindex }) => {
}> = ({ frozen, closeFlyout, reindexState, startReindex, cancelReindex }) => {
const {
services: {
api,
Expand Down Expand Up @@ -197,6 +198,37 @@ export const ChecklistFlyoutStep: React.FunctionComponent<{
}}
/>
</p>
{frozen && (
<>
<EuiCallOut
title={
<FormattedMessage
id="xpack.upgradeAssistant.checkupTab.reindexing.flyout.checklistStep.reindexFrozenIndexTitle"
defaultMessage="This index is frozen"
/>
}
iconType="iInCircle"
>
<FormattedMessage
id="xpack.upgradeAssistant.checkupTab.reindexing.flyout.checklistStep.reindexFrozenIndex"
defaultMessage="Frozen indices will no longer be supported after upgrade, so this index will be deleted as part the reindex operation. {docsLink}"
values={{
docsLink: (
<EuiLink target="_blank" href={docLinks.links.upgradeAssistant.unfreezeApi}>
{i18n.translate(
'xpack.upgradeAssistant.checkupTab.reindexing.flyout.learnMoreLinkLabel',
{
defaultMessage: 'Learn more',
}
)}
</EuiLink>
),
}}
/>
</EuiCallOut>
<EuiSpacer />
</>
)}
<p>
<FormattedMessage
id="xpack.upgradeAssistant.checkupTab.reindexing.flyout.checklistStep.readonlyCallout.backgroundResumeDetail"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ export const ReindexFlyout: React.FunctionComponent<ReindexFlyoutProps> = ({
/>
) : (
<ChecklistFlyoutStep
frozen={deprecation.frozen}
closeFlyout={closeFlyout}
startReindex={startReindexWithWarnings}
reindexState={reindexState}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,25 @@
"resolve_during_rolling_upgrade": false
}
],
"frozen_index": [
{
"level": "critical",
"message": "Old index with a compatibility version < 8.0",
"url": "https://www.elastic.co/guide/en/elasticsearch/reference/current/migrating-8.0.html#breaking-changes-8.0",
"details": "This index has version: 7.17.28-8.0.0",
"resolve_during_rolling_upgrade": false,
"_meta": { "reindex_required": true }
},
{
"level": "critical",
"message":
"Index [frozen_index] is a frozen index. The frozen indices feature is deprecated and will be removed in version 9.0.",
"url": "https://www.elastic.co/guide/en/elasticsearch/reference/master/frozen-indices.html",
"details":
"Frozen indices must be unfrozen before upgrading to version 9.0. (The legacy frozen indices feature no longer offers any advantages. You may consider cold or frozen tiers in place of frozen indices.)",
"resolve_during_rolling_upgrade": false
}
],
"closed_index": [
{
"level": "critical",
Expand Down

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

Original file line number Diff line number Diff line change
Expand Up @@ -238,6 +238,52 @@ describe('getESUpgradeStatus', () => {
expect(upgradeStatus.totalCriticalDeprecations).toBe(0);
});

it('filters out frozen indices if old index deprecations exist for the same indices', async () => {
esClient.asCurrentUser.migration.deprecations.mockResponse({
cluster_settings: [],
node_settings: [],
ml_settings: [],
index_settings: {
frozen_index: [
{
level: 'critical',
message: 'Old index with a compatibility version < 8.0',
url: 'https://www.elastic.co/guide/en/elasticsearch/reference/current/migrating-8.0.html#breaking-changes-8.0',
details: 'This index has version: 7.17.28-8.0.0',
resolve_during_rolling_upgrade: false,
_meta: { reindex_required: true },
},
{
level: 'critical',
message:
'Index [frozen_index] is a frozen index. The frozen indices feature is deprecated and will be removed in version 9.0.',
url: 'https://www.elastic.co/guide/en/elasticsearch/reference/master/frozen-indices.html',
details:
'Frozen indices must be unfrozen before upgrading to version 9.0. (The legacy frozen indices feature no longer offers any advantages. You may consider cold or frozen tiers in place of frozen indices.)',
resolve_during_rolling_upgrade: false,
},
],
},
data_streams: {},
// @ts-expect-error not in types yet
ilm_policies: {},
templates: {},
});

// @ts-expect-error not full interface of response
esClient.asCurrentUser.indices.resolveIndex.mockResponse(resolvedIndices);

const upgradeStatus = await getESUpgradeStatus(esClient, {
...featureSet,
});

expect([
...upgradeStatus.migrationsDeprecations,
...upgradeStatus.enrichedHealthIndicators,
]).toHaveLength(1);
expect(upgradeStatus.totalCriticalDeprecations).toBe(1);
});

it('returns health indicators', async () => {
esClient.asCurrentUser.migration.deprecations.mockResponse({
cluster_settings: [],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -127,13 +127,13 @@ export const getEnrichedDeprecations = async (

const systemIndicesList = convertFeaturesToIndicesArray(systemIndices.features);

const indexSettingsIndexNames = Object.keys(deprecations.index_settings).map(
(indexName) => indexName!
);
const indexSettingsIndexNames = Object.keys(deprecations.index_settings);
const indexSettingsIndexStates = indexSettingsIndexNames.length
? await esIndicesStateCheck(dataClient.asCurrentUser, indexSettingsIndexNames)
: {};

const deprecationsByIndex = new Map<string, EnrichedDeprecationInfo[]>();

return normalizeEsResponse(deprecations)
.filter((deprecation) => {
switch (deprecation.type) {
Expand Down Expand Up @@ -174,10 +174,39 @@ export const getEnrichedDeprecations = async (
indexSettingsIndexStates[deprecation.index!] === 'closed' ? 'index-closed' : undefined;
}

const enrichedDeprecation = _.omit(deprecation, 'metadata');
return {
...enrichedDeprecation,
const enrichedDeprecation = {
..._.omit(deprecation, 'metadata'),
correctiveAction,
};

if (deprecation.index) {
const indexDeprecations = deprecationsByIndex.get(deprecation.index) || [];
indexDeprecations.push(enrichedDeprecation);
deprecationsByIndex.set(deprecation.index, indexDeprecations);
}

return enrichedDeprecation;
})
.filter((deprecation) => {
if (
deprecation.index &&
deprecation.message.includes(`Index [${deprecation.index}] is a frozen index`)
) {
// frozen indices are created in 7.x, so they are old / incompatible as well
// reindexing + deleting is required, so no need to bubble up this deprecation in the UI
const indexDeprecations = deprecationsByIndex.get(deprecation.index)!;
const oldIndexDeprecation: EnrichedDeprecationInfo | undefined = indexDeprecations.find(
(elem) =>
elem.type === 'index_settings' &&
elem.index === deprecation.index &&
elem.correctiveAction?.type === 'reindex'
);
if (oldIndexDeprecation) {
oldIndexDeprecation.frozen = true;
return false;
}
}

return true;
});
};

0 comments on commit cc358e3

Please sign in to comment.