Skip to content

Commit

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

## Summary

Fixes elastic#180970 

In `indexLifecycleDataEnricher`, add `only_managed: true` query
parameter to fetch lifecycle data.

It causes the `ilm` property to be empty in the response. And
`EuiSearchBar` `field_value_selection` doesn't support filtering a
`undefined` filed value.

So, maybe `only_managed: true` should be removed.

Before:

<img width="733" alt="image"
src="https://github.com/user-attachments/assets/2472127d-c050-4ffb-bb76-f3e80e780cb3">

After: 

<img width="511" alt="image"
src="https://github.com/user-attachments/assets/da38f437-58f4-43b2-8d6b-54873e01f79b">

Co-authored-by: Elastic Machine <[email protected]>
Co-authored-by: Elena Stoeva <[email protected]>
  • Loading branch information
3 people authored Oct 10, 2024
1 parent dffe0b5 commit 5214877
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 5214877

Please sign in to comment.