Skip to content

Commit

Permalink
[8.x] [Index Management] Fix filter index list by lifecycle status (#…
Browse files Browse the repository at this point in the history
…195350) (#195803)

# Backport

This will backport the following commits from `main` to `8.x`:
- [[Index Management] Fix filter index list by lifecycle status
(#195350)](#195350)

<!--- Backport version: 9.4.3 -->

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

<!--BACKPORT [{"author":{"name":"Jusheng
Huang","email":"[email protected]"},"sourceCommit":{"committedDate":"2024-10-10T16:05:23Z","message":"[Index
Management] Fix filter index list by lifecycle status (#195350)\n\n##
Summary\r\n\r\nFixes #180970 \r\n\r\nIn `indexLifecycleDataEnricher`,
add `only_managed: true` query\r\nparameter to fetch lifecycle
data.\r\n\r\nIt causes the `ilm` property to be empty in the response.
And\r\n`EuiSearchBar` `field_value_selection` doesn't support filtering
a\r\n`undefined` filed value.\r\n\r\nSo, maybe `only_managed: true`
should be removed.\r\n\r\nBefore:\r\n\r\n<img width=\"733\"
alt=\"image\"\r\nsrc=\"https://github.com/user-attachments/assets/2472127d-c050-4ffb-bb76-f3e80e780cb3\">\r\n\r\nAfter:
\r\n\r\n<img width=\"511\"
alt=\"image\"\r\nsrc=\"https://github.com/user-attachments/assets/da38f437-58f4-43b2-8d6b-54873e01f79b\">\r\n\r\nCo-authored-by:
Elastic Machine
<[email protected]>\r\nCo-authored-by: Elena
Stoeva
<[email protected]>","sha":"52148775b1ff4b4379f0049cc2332fb27e405a07","branchLabelMapping":{"^v9.0.0$":"main","^v8.16.0$":"8.x","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["Team:Kibana
Management","release_note:skip","💝community","v9.0.0","backport:prev-minor"],"title":"[Index
Management] Fix filter index list by lifecycle
status","number":195350,"url":"https://github.com/elastic/kibana/pull/195350","mergeCommit":{"message":"[Index
Management] Fix filter index list by lifecycle status (#195350)\n\n##
Summary\r\n\r\nFixes #180970 \r\n\r\nIn `indexLifecycleDataEnricher`,
add `only_managed: true` query\r\nparameter to fetch lifecycle
data.\r\n\r\nIt causes the `ilm` property to be empty in the response.
And\r\n`EuiSearchBar` `field_value_selection` doesn't support filtering
a\r\n`undefined` filed value.\r\n\r\nSo, maybe `only_managed: true`
should be removed.\r\n\r\nBefore:\r\n\r\n<img width=\"733\"
alt=\"image\"\r\nsrc=\"https://github.com/user-attachments/assets/2472127d-c050-4ffb-bb76-f3e80e780cb3\">\r\n\r\nAfter:
\r\n\r\n<img width=\"511\"
alt=\"image\"\r\nsrc=\"https://github.com/user-attachments/assets/da38f437-58f4-43b2-8d6b-54873e01f79b\">\r\n\r\nCo-authored-by:
Elastic Machine
<[email protected]>\r\nCo-authored-by: Elena
Stoeva
<[email protected]>","sha":"52148775b1ff4b4379f0049cc2332fb27e405a07"}},"sourceBranch":"main","suggestedTargetBranches":[],"targetPullRequestStates":[{"branch":"main","label":"v9.0.0","branchLabelMappingKey":"^v9.0.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/195350","number":195350,"mergeCommit":{"message":"[Index
Management] Fix filter index list by lifecycle status (#195350)\n\n##
Summary\r\n\r\nFixes #180970 \r\n\r\nIn `indexLifecycleDataEnricher`,
add `only_managed: true` query\r\nparameter to fetch lifecycle
data.\r\n\r\nIt causes the `ilm` property to be empty in the response.
And\r\n`EuiSearchBar` `field_value_selection` doesn't support filtering
a\r\n`undefined` filed value.\r\n\r\nSo, maybe `only_managed: true`
should be removed.\r\n\r\nBefore:\r\n\r\n<img width=\"733\"
alt=\"image\"\r\nsrc=\"https://github.com/user-attachments/assets/2472127d-c050-4ffb-bb76-f3e80e780cb3\">\r\n\r\nAfter:
\r\n\r\n<img width=\"511\"
alt=\"image\"\r\nsrc=\"https://github.com/user-attachments/assets/da38f437-58f4-43b2-8d6b-54873e01f79b\">\r\n\r\nCo-authored-by:
Elastic Machine
<[email protected]>\r\nCo-authored-by: Elena
Stoeva
<[email protected]>","sha":"52148775b1ff4b4379f0049cc2332fb27e405a07"}}]}]
BACKPORT-->

Co-authored-by: Jusheng Huang <[email protected]>
  • Loading branch information
kibanamachine and viajes7 authored Oct 10, 2024
1 parent ae803ed commit c7fa004
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 5 deletions.
1 change: 0 additions & 1 deletion x-pack/plugins/index_lifecycle_management/server/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ const indexLifecycleDataEnricher = async (

const { indices: ilmIndicesData } = await client.asCurrentUser.ilm.explainLifecycle({
index: '*,.*',
only_managed: true,
});
return indicesList.map((index: Index) => {
return {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,16 +55,17 @@ export default function ({ getService }: FtrProviderContext) {
const testAlias = 'test_alias';
const testIlmPolicy = 'test_policy';
describe('GET indices with data enrichers', () => {
before(async () => {
beforeEach(async () => {
await createIndex(testIndex);
await createIlmPolicy('test_policy');
await addPolicyToIndex(testIlmPolicy, testIndex, testAlias);
});
after(async () => {
afterEach(async () => {
await esDeleteAllIndices([testIndex]);
});

it(`ILM data is fetched by the ILM data enricher`, async () => {
await createIlmPolicy('test_policy');
await addPolicyToIndex(testIlmPolicy, testIndex, testAlias);

const { body: indices } = await supertest
.get(`${API_BASE_PATH}/indices`)
.set('kbn-xsrf', 'xxx')
Expand All @@ -75,5 +76,18 @@ export default function ({ getService }: FtrProviderContext) {
const { ilm } = index;
expect(ilm.policy).to.eql(testIlmPolicy);
});

it(`ILM data is not empty even if the index unmanaged`, async () => {
const { body: indices } = await supertest
.get(`${API_BASE_PATH}/indices`)
.set('kbn-xsrf', 'xxx')
.expect(200);

const index = indices.find((item: Index) => item.name === testIndex);

const { ilm } = index;
expect(ilm.index).to.eql(testIndex);
expect(ilm.managed).to.eql(false);
});
});
}

0 comments on commit c7fa004

Please sign in to comment.