[8.18] [UA] Use reindex_required metadata to drive corrective actions (#214532) (#214643)

# Backport

This will backport the following commits from `8.x` to `8.18`:
- [[UA] Use `reindex_required` metadata to drive corrective actions
(#214532)](https://github.com/elastic/kibana/pull/214532)

<!--- Backport version: 9.6.6 -->

### Questions ?
Please refer to the [Backport tool
documentation](https://github.com/sorenlouv/backport)

<!--BACKPORT [{"author":{"name":"Jean-Louis
Leysens","email":"jeanlouis.leysens@elastic.co"},"sourceCommit":{"committedDate":"2025-03-14T18:50:43Z","message":"[UA]
Use `reindex_required` metadata to drive corrective actions
(#214532)\n\n## Summary\n\nTested locally and critical old data
deprecations are still surfaced as\nexpected\n\n<img width=\"586\"
alt=\"Screenshot 2025-03-14 at 10 12
50\"\nsrc=\"https://github.com/user-attachments/assets/25d87fbd-7c98-45e0-a86a-d513ea455571\"\n/>","sha":"26aba9287821f289deb11b27079a9a7d0945c714","branchLabelMapping":{"^v8.16.0$":"main","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["Team:Core","release_note:skip","Feature:Upgrade
Assistant","backport:version","v8.18.0","v8.19.0","v8.18.1"],"title":"[UA]
Use `reindex_required` metadata to drive corrective
actions","number":214532,"url":"https://github.com/elastic/kibana/pull/214532","mergeCommit":{"message":"[UA]
Use `reindex_required` metadata to drive corrective actions
(#214532)\n\n## Summary\n\nTested locally and critical old data
deprecations are still surfaced as\nexpected\n\n<img width=\"586\"
alt=\"Screenshot 2025-03-14 at 10 12
50\"\nsrc=\"https://github.com/user-attachments/assets/25d87fbd-7c98-45e0-a86a-d513ea455571\"\n/>","sha":"26aba9287821f289deb11b27079a9a7d0945c714"}},"sourceBranch":"8.x","suggestedTargetBranches":["8.18"],"targetPullRequestStates":[{"branch":"8.18","label":"v8.18.0","branchLabelMappingKey":"^v(\\d+).(\\d+).\\d+$","isSourceBranch":false,"state":"NOT_CREATED"},{"branch":"8.19","label":"v8.19.0","branchLabelMappingKey":"^v(\\d+).(\\d+).\\d+$","isSourceBranch":false,"state":"NOT_CREATED"}]}]
BACKPORT-->
This commit is contained in:
Jean-Louis Leysens 2025-03-17 13:31:28 +01:00 committed by GitHub
parent 4d203877e4
commit 80ca1caf91
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 28 additions and 14 deletions

View file

@ -69,7 +69,10 @@
"message": "Index created before 7.0",
"url": "https: //www.elastic.co/guide/en/elasticsearch/reference/master/breaking-changes-8.0.html",
"details": "This index was created using version: 6.8.13",
"resolve_during_rolling_upgrade": false
"resolve_during_rolling_upgrade": false,
"_meta": {
"reindex_required": true
}
}
],
"frozen_index": [
@ -97,7 +100,10 @@
"message": "Index created before 7.0",
"url": "https: //www.elastic.co/guide/en/elasticsearch/reference/master/breaking-changes-8.0.html",
"details": "This index was created using version: 6.8.13",
"resolve_during_rolling_upgrade": false
"resolve_during_rolling_upgrade": false,
"_meta": {
"reindex_required": true
}
}
],
"deprecated_settings": [
@ -183,7 +189,10 @@
"message": "Old index with a compatibility version < 8.0",
"url": "https://www.elastic.co/guide/en/elasticsearch/reference/master/breaking-changes-9.0.html",
"details": "This index has version: 7.17.25",
"resolve_during_rolling_upgrade": false
"resolve_during_rolling_upgrade": false,
"_meta": {
"reindex_required": true
}
}
],
".ent-search-1": [

View file

@ -44,12 +44,6 @@ interface DataStreamActionMetadata extends CommonActionMetadata {
export type EsMetadata = IndexActionMetadata | MlActionMetadata | DataStreamActionMetadata;
// TODO(jloleysens): Replace these regexes once this issue is addressed https://github.com/elastic/elasticsearch/issues/118062
const ES_INDEX_MESSAGES_REQUIRING_REINDEX = [
/Index created before/,
/index with a compatibility version \</,
];
export const isFrozenDeprecation = (message: string, indexName?: string): boolean =>
Boolean(indexName) && message.includes(`Index [${indexName}] is a frozen index`);
@ -62,9 +56,9 @@ export const getCorrectiveAction = (deprecation: BaseDeprecation): CorrectiveAct
const clusterSettingDeprecation = metadata?.actions?.find(
(action) => action.action_type === 'remove_settings' && typeof index === 'undefined'
);
const requiresReindexAction = ES_INDEX_MESSAGES_REQUIRING_REINDEX.some((regexp) =>
regexp.test(message)
);
const requiresReindexAction =
(type === 'index_settings' || type === 'node_settings') &&
(deprecation.metadata as IndexActionMetadata)?.reindex_required === true;
const requiresUnfreezeAction = isFrozenDeprecation(message, index);
const requiresIndexSettingsAction = Boolean(indexSettingDeprecation);
const requiresClusterSettingsAction = Boolean(clusterSettingDeprecation);

View file

@ -219,6 +219,9 @@ describe('getESUpgradeStatus', () => {
details: 'This index was created using version: 6.8.13',
// @ts-ignore
resolve_during_rolling_upgrade: false,
_meta: {
reindex_required: true,
},
},
{
level: 'critical',
@ -227,6 +230,9 @@ describe('getESUpgradeStatus', () => {
details: 'This index was created using version: 6.8.13',
// @ts-ignore
resolve_during_rolling_upgrade: false,
_meta: {
reindex_required: true,
},
},
],
ml_settings: [],
@ -394,6 +400,9 @@ describe('getESUpgradeStatus', () => {
details: 'This index was created using version: 6.8.13',
// @ts-ignore
resolve_during_rolling_upgrade: false,
_meta: {
reindex_required: true,
},
},
],
ml_settings: [],

View file

@ -207,7 +207,7 @@ export default function ({ getService }: FtrProviderContext) {
);
});
});
it('GET /api/upgrade_assistant/status does not return { readyForUpgrade: false } if there are only critical API deprecations', async () => {
it('Readiness status excludes critical deprecations based on Kibana API usage', async () => {
/** Throw in another critical deprecation... */
await supertest.get(`/api/routing_example/d/removed_route`).expect(200);
// sleep a little until the usage counter is synced into ES
@ -224,7 +224,9 @@ export default function ({ getService }: FtrProviderContext) {
2000
);
const { body } = await supertest.get(`/api/upgrade_assistant/status`).expect(200);
// There are critical deprecations, but we expect none of them to be related to Kibana
// There are critical deprecations for Kibana API usage, but we do not
// surface them in readiness status
expect(body.readyForUpgrade).to.be(false);
expect(body.details?.length > 0).to.be(true);
expect(/Kibana/gi.test(body.details)).to.be(false);