Skip to content

Commit

Permalink
[ILM] Fix missing ILM data on hidden indices (#176178)
Browse files Browse the repository at this point in the history
## Summary

Fixes #88441

This PR fixes the ILM data enricher to fetch the ILM data for hidden
indices, it also sets the response from ES to only return ILM data for
indices that are managed by ILM.

To test this fix, follow these steps:
1. Add a sample data set
2. Navigate to Discover and click "share" to create a CSV report
3. Navigate to ILM and toggle "include managed policies"
4. Find the ILM policy "kibana-reporting" and click the link for linked
indices
5. In Index Management check that the linked index ".reporting*" is
found in the table and has the ILM data attached to it

### Screenshot 
<img width="1118" alt="Screenshot 2024-02-02 at 18 14 50"
src="https://github.com/elastic/kibana/assets/6585477/e1f7c8d2-69f1-4925-a613-6b0b0a6a72d5">



### Checklist

Delete any items that are not applicable to this PR.

- [ ] Any text added follows [EUI's writing
guidelines](https://elastic.github.io/eui/#/guidelines/writing), uses
sentence case text and includes [i18n
support](https://github.com/elastic/kibana/blob/main/packages/kbn-i18n/README.md)
- [ ]
[Documentation](https://www.elastic.co/guide/en/kibana/master/development-documentation.html)
was added for features that require explanation or tutorials
- [ ] [Unit or functional
tests](https://www.elastic.co/guide/en/kibana/master/development-tests.html)
were updated or added to match the most common scenarios
- [ ] [Flaky Test
Runner](https://ci-stats.kibana.dev/trigger_flaky_test_runner/1) was
used on any tests changed
- [ ] Any UI touched in this PR is usable by keyboard only (learn more
about [keyboard accessibility](https://webaim.org/techniques/keyboard/))
- [ ] Any UI touched in this PR does not create any new axe failures
(run axe in browser:
[FF](https://addons.mozilla.org/en-US/firefox/addon/axe-devtools/),
[Chrome](https://chrome.google.com/webstore/detail/axe-web-accessibility-tes/lhdoppojpmngadmnindnejefpokejbdd?hl=en-US))
- [ ] If a plugin configuration key changed, check if it needs to be
allowlisted in the cloud and added to the [docker
list](https://github.com/elastic/kibana/blob/main/src/dev/build/tasks/os_packages/docker_generator/resources/base/bin/kibana-docker)
- [ ] This renders correctly on smaller devices using a responsive
layout. (You can test this [in your
browser](https://www.browserstack.com/guide/responsive-testing-on-local-server))
- [ ] This was checked for [cross-browser
compatibility](https://www.elastic.co/support/matrix#matrix_browsers)


### Risk Matrix

Delete this section if it is not applicable to this PR.

Before closing this PR, invite QA, stakeholders, and other developers to
identify risks that should be tested prior to the change/feature
release.

When forming the risk matrix, consider some of the following examples
and how they may potentially impact the change:

| Risk | Probability | Severity | Mitigation/Notes |

|---------------------------|-------------|----------|-------------------------|
| Multiple Spaces&mdash;unexpected behavior in non-default Kibana Space.
| Low | High | Integration tests will verify that all features are still
supported in non-default Kibana Space and when user switches between
spaces. |
| Multiple nodes&mdash;Elasticsearch polling might have race conditions
when multiple Kibana nodes are polling for the same tasks. | High | Low
| Tasks are idempotent, so executing them multiple times will not result
in logical error, but will degrade performance. To test for this case we
add plenty of unit tests around this logic and document manual testing
procedure. |
| Code should gracefully handle cases when feature X or plugin Y are
disabled. | Medium | High | Unit tests will verify that any feature flag
or plugin combination still results in our service operational. |
| [See more potential risk
examples](https://github.com/elastic/kibana/blob/main/RISK_MATRIX.mdx) |


### For maintainers

- [ ] This was checked for breaking API changes and was [labeled
appropriately](https://www.elastic.co/guide/en/kibana/master/contributing.html#kibana-release-notes-process)

Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com>
  • Loading branch information
yuliacech and kibanamachine authored Feb 5, 2024
1 parent 3ef1e76 commit 38e8657
Show file tree
Hide file tree
Showing 4 changed files with 96 additions and 1 deletion.
3 changes: 2 additions & 1 deletion x-pack/plugins/index_lifecycle_management/server/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@ const indexLifecycleDataEnricher = async (
}

const { indices: ilmIndicesData } = await client.asCurrentUser.ilm.explainLifecycle({
index: '*',
index: '*,.*',
only_managed: true,
});
return indicesList.map((index: Index) => {
return {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the Elastic License
* 2.0; you may not use this file except in compliance with the Elastic License
* 2.0.
*/

import expect from '@kbn/expect';
import { API_BASE_PATH, Index } from '@kbn/index-management-plugin/common';
import { FtrProviderContext } from '../../../../ftr_provider_context';

export default function ({ getService }: FtrProviderContext) {
const supertest = getService('supertest');
const es = getService('es');
const esDeleteAllIndices = getService('esDeleteAllIndices');
const createIndex = async (name: string) => {
await es.indices.create({
index: name,
settings: {
hidden: true,
},
});
};

const createIlmPolicy = async (policyName: string) => {
await es.ilm.putLifecycle({
name: policyName,
policy: {
phases: {
hot: {
min_age: '1d',
actions: {
set_priority: {
priority: 100,
},
},
},
},
},
});
};

const addPolicyToIndex = async (policyName: string, indexName: string, rolloverAlias: string) => {
await es.indices.putSettings({
index: indexName,
settings: {
lifecycle: {
name: policyName,
rollover_alias: rolloverAlias,
},
},
});
};
const testIndex = '.test_index';
const testAlias = 'test_alias';
const testIlmPolicy = 'test_policy';
describe('GET indices with data enrichers', async () => {
before(async () => {
await createIndex(testIndex);
await createIlmPolicy('test_policy');
await addPolicyToIndex(testIlmPolicy, testIndex, testAlias);
});
after(async () => {
await esDeleteAllIndices([testIndex]);
});

it(`ILM data is fetched by the ILM data enricher`, 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.policy).to.eql(testIlmPolicy);
});
});
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the Elastic License
* 2.0; you may not use this file except in compliance with the Elastic License
* 2.0.
*/

import { FtrProviderContext } from '../../../../ftr_provider_context';

export default ({ loadTestFile }: FtrProviderContext) => {
describe('Index Management: data enrichers', function () {
loadTestFile(require.resolve('./ilm'));
});
};
Original file line number Diff line number Diff line change
Expand Up @@ -20,5 +20,6 @@ export default function ({ loadTestFile }: FtrProviderContext) {
loadTestFile(require.resolve('./index_details'));
loadTestFile(require.resolve('./enrich_policies'));
loadTestFile(require.resolve('./create_enrich_policy'));
loadTestFile(require.resolve('./data_enrichers'));
});
}

0 comments on commit 38e8657

Please sign in to comment.