Skip to content

Commit

Permalink
[ILM] Update the ILM tab on the index details page (#170726)
Browse files Browse the repository at this point in the history
## Summary

Fixes #170516
This PR updates how the ILM tab is rendered on the index details page to
make it look more fitting with other tabs.

### Screenshots 

#### ILM is waiting for a step to complete
<img width="1448" alt="Screenshot 2023-11-14 at 15 06 10"
src="https://github.com/elastic/kibana/assets/6585477/47642cd5-3a22-44ee-b49f-0a87713eba3b">


#### ILM has an error
<img width="1450" alt="Screenshot 2023-11-14 at 15 05 23"
src="https://github.com/elastic/kibana/assets/6585477/78a7af30-5ba1-4a74-b5fe-c359341f20f4">



#### ILM has no errors and is not waiting for a step
<img width="1460" alt="Screenshot 2023-11-14 at 15 04 57"
src="https://github.com/elastic/kibana/assets/6585477/43b215e0-d56f-4fb8-927f-35a7c2b1b313">



### How to test
I recommend using a chrome extension to mock the backend responses, for
example https://tweak-extension.com/docs/intro.
To mock the response of the index request, configure the extension to
mock the url `/internal/index_management/indices/` and let it return
various ilm configurations:

<details>

<summary>index with ILM that is waiting for a step to complete
</summary>

```json
{
  "health": "green",
  "status": "open",
  "name": "test",
  "uuid": "cJYz9o4jTjuAZaMNS3ERyQ",
  "primary": "1",
  "replica": "0",
  "documents": 23654,
  "documents_deleted": 0,
  "size": "248b",
  "primary_size": "248b",
  "isFrozen": false,
  "aliases": "none",
  "hidden": false,
  "isRollupIndex": false,
  "ilm": {
    "index": "test-000020",
    "index_creation_date_millis": 1538475653281,
    "time_since_index_creation": "4.12m",
    "managed": true,
    "policy": "my_lifecycle3",
    "lifecycle_date_millis": 1538475653281,
    "lifecycle_date": "2018-10-15T13:45:21.981Z",
    "age": "4.12m",
    "phase": "warm",
    "phase_time_millis": 1538475653317,
    "phase_time": "2018-10-15T13:45:22.577Z",
    "action": "allocate",
    "action_time_millis": 1538475653317,
    "action_time": "2018-10-15T13:45:22.577Z",
    "step": "check-allocation",
    "step_time_millis": 1538475653317,
    "step_time": "2018-10-15T13:45:22.577Z",
    "step_info": {
      "message": "Waiting for all shard copies to be active",
      "shards_left_to_allocate": -1,
      "all_shards_active": false,
      "number_of_replicas": 2
    },
    "phase_execution": {
      "policy": "my_lifecycle3",
      "phase_definition": {
        "min_age": "0ms",
        "actions": {
          "allocate": {
            "number_of_replicas": 2,
            "include": {
              "box_type": "warm"
            },
            "exclude": {},
            "require": {}
          },
          "forcemerge": {
            "max_num_segments": 1
          }
        }
      },
      "version": 2,
      "modified_date": "2018-10-15T13:20:02.489Z",
      "modified_date_in_millis": 1539609602489
    }
  },
  "isFollowerIndex": false
}

```
</details>

<details>
<summary>index with ILM that has an error</summary>

```json
{
  "health": "green",
  "status": "open",
  "name": "test",
  "uuid": "cJYz9o4jTjuAZaMNS3ERyQ",
  "primary": "1",
  "replica": "0",
  "documents": 23654,
  "documents_deleted": 0,
  "size": "248b",
  "primary_size": "248b",
  "isFrozen": false,
  "aliases": "none",
  "hidden": false,
  "isRollupIndex": false,
  "ilm": {
    "index": "test-000056",
    "index_creation_date_millis": 1538475653281,
    "time_since_index_creation": "50.1d",
    "managed": true,
    "policy": "my_lifecycle3",
    "lifecycle_date_millis": 1538475653281,
    "lifecycle_date": "2018-10-15T13:45:21.981Z",
    "age": "50.1d",
    "phase": "hot",
    "phase_time_millis": 1538475653317,
    "phase_time": "2018-10-15T13:45:22.577Z",
    "action": "rollover",
    "action_time_millis": 1538475653317,
    "action_time": "2018-10-15T13:45:22.577Z",
    "step": "ERROR",
    "step_time_millis": 1538475653317,
    "step_time": "2018-10-15T13:45:22.577Z",
    "failed_step": "check-rollover-ready",
    "is_auto_retryable_error": true,
    "failed_step_retry_count": 1,
    "step_info": {
      "type": "cluster_block_exception",
      "reason": "index [test-000057/H7lF9n36Rzqa-KfKcnGQMg] blocked by: [FORBIDDEN/5/index read-only (api)",
      "index_uuid": "H7lF9n36Rzqa-KfKcnGQMg",
      "index": "test-000057"
    },
    "phase_execution": {
      "policy": "my_lifecycle3",
      "phase_definition": {
        "min_age": "0ms",
        "actions": {
          "rollover": {
            "max_age": "30s"
          }
        }
      },
      "version": 3,
      "modified_date": "2018-10-15T13:21:41.576Z",
      "modified_date_in_millis": 1539609701576
    }
  },
  "isFollowerIndex": false
}
```

</details>


### Checklist


- [ ] 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
- [ ] 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)

### Release Note
The ILM summary on the index page is now displayed in a separate tab.

---------

Co-authored-by: kibanamachine <42973632+kibanamachine@users.noreply.github.com>
  • Loading branch information
yuliacech and kibanamachine committed Nov 15, 2023
1 parent b05abd4 commit 88c313e
Show file tree
Hide file tree
Showing 8 changed files with 820 additions and 365 deletions.

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import { init as initHttp } from '../public/application/services/http';
import { init as initUiMetric } from '../public/application/services/ui_metric';
import { indexLifecycleTab } from '../public/extend_index_management/components/index_lifecycle_summary';
import { Index } from '@kbn/index-management-plugin/common';
import { findTestSubject } from '@elastic/eui/lib/test';

const { httpSetup } = init();

Expand Down Expand Up @@ -111,6 +112,33 @@ const indexWithLifecycleError: Index = {
type: 'illegal_argument_exception',
reason: 'setting [index.lifecycle.rollover_alias] for index [testy3] is empty or not defined',
},
},
};
const indexWithLifecyclePhaseDefinition: Index = {
health: 'yellow',
status: 'open',
name: 'testy3',
uuid: 'XL11TLa3Tvq298_dMUzLHQ',
primary: 1,
replica: 1,
documents: 2,
documents_deleted: 0,
size: '6.5kb',
primary_size: '6.5kb',
aliases: 'none',
isFrozen: false,
hidden: false,
ilm: {
index: 'testy3',
managed: true,
policy: 'testy',
lifecycle_date_millis: 1544020872361,
phase: 'hot',
phase_time_millis: 1544187775891,
action: 'rollover',
action_time_millis: 1544187775891,
step: 'test',
step_time_millis: 1544187776208,
phase_execution: {
policy: 'testy',
// @ts-expect-error ILM type is incorrect https://github.com/elastic/elasticsearch-specification/issues/2326
Expand All @@ -120,6 +148,39 @@ const indexWithLifecycleError: Index = {
},
},
};
const indexWithLifecycleWaitingStep: Index = {
health: 'yellow',
status: 'open',
name: 'testy3',
uuid: 'XL11TLa3Tvq298_dMUzLHQ',
primary: 1,
replica: 1,
documents: 2,
documents_deleted: 0,
size: '6.5kb',
primary_size: '6.5kb',
aliases: 'none',
isFrozen: false,
hidden: false,
ilm: {
index: 'testy3',
managed: true,
policy: 'testy',
lifecycle_date_millis: 1544020872361,
phase: 'hot',
phase_time_millis: 1544187775891,
action: 'rollover',
action_time_millis: 1544187775891,
step: 'test',
step_time_millis: 1544187776208,
step_info: {
message: 'Waiting for all shard copies to be active',
shards_left_to_allocate: -1,
all_shards_active: false,
number_of_replicas: 2,
},
},
};

moment.tz.setDefault('utc');

Expand Down Expand Up @@ -245,6 +306,11 @@ describe('extend index management', () => {

describe('ilm summary extension', () => {
const IlmComponent = indexLifecycleTab.renderTabContent;
const policyPropertiesPanel = 'policyPropertiesPanel';
const policyStepPanel = 'policyStepPanel';
const policyErrorPanel = 'policyErrorPanel';
const phaseDefinitionPanel = 'phaseDefinitionPanel';

test('should not render the tab when index has no index lifecycle policy', () => {
const shouldRenderTab =
indexLifecycleTab.shouldRenderTab &&
Expand All @@ -254,22 +320,58 @@ describe('extend index management', () => {
expect(shouldRenderTab).toBeFalsy();
});

test('should return extension when index has lifecycle policy', () => {
test('should render the tab when index has lifecycle policy', () => {
const shouldRenderTab =
indexLifecycleTab.shouldRenderTab &&
indexLifecycleTab.shouldRenderTab({
index: indexWithLifecyclePolicy,
});
expect(shouldRenderTab).toBeTruthy();
const ilmContent = (
<IlmComponent index={indexWithLifecyclePolicy} getUrlForApp={getUrlForApp} />
);
expect(ilmContent).toBeDefined();
const rendered = mountWithIntl(ilmContent);
expect(rendered.render()).toMatchSnapshot();
expect(findTestSubject(rendered, policyPropertiesPanel).exists()).toBeTruthy();
expect(findTestSubject(rendered, phaseDefinitionPanel).exists()).toBeFalsy();
expect(findTestSubject(rendered, policyStepPanel).exists()).toBeFalsy();
expect(findTestSubject(rendered, policyErrorPanel).exists()).toBeFalsy();
});

test('should return extension when index has lifecycle error', () => {
test('should render an error panel when index has lifecycle error', () => {
const ilmContent = (
<IlmComponent index={indexWithLifecycleError} getUrlForApp={getUrlForApp} />
);
expect(ilmContent).toBeDefined();
const rendered = mountWithIntl(ilmContent);
expect(rendered.render()).toMatchSnapshot();
expect(findTestSubject(rendered, policyPropertiesPanel).exists()).toBeTruthy();
expect(findTestSubject(rendered, phaseDefinitionPanel).exists()).toBeFalsy();
expect(findTestSubject(rendered, policyStepPanel).exists()).toBeFalsy();
expect(findTestSubject(rendered, policyErrorPanel).exists()).toBeTruthy();
});

test('should render a phase definition panel when lifecycle has phase definition', () => {
const ilmContent = (
<IlmComponent index={indexWithLifecyclePhaseDefinition} getUrlForApp={getUrlForApp} />
);
const rendered = mountWithIntl(ilmContent);
expect(rendered.render()).toMatchSnapshot();
expect(findTestSubject(rendered, policyPropertiesPanel).exists()).toBeTruthy();
expect(findTestSubject(rendered, phaseDefinitionPanel).exists()).toBeTruthy();
expect(findTestSubject(rendered, policyStepPanel).exists()).toBeFalsy();
expect(findTestSubject(rendered, policyErrorPanel).exists()).toBeFalsy();
});

test('should render a step info panel when lifecycle is waiting for a step completion', () => {
const ilmContent = (
<IlmComponent index={indexWithLifecycleWaitingStep} getUrlForApp={getUrlForApp} />
);
const rendered = mountWithIntl(ilmContent);
expect(rendered.render()).toMatchSnapshot();
expect(findTestSubject(rendered, policyPropertiesPanel).exists()).toBeTruthy();
expect(findTestSubject(rendered, phaseDefinitionPanel).exists()).toBeFalsy();
expect(findTestSubject(rendered, policyStepPanel).exists()).toBeTruthy();
expect(findTestSubject(rendered, policyErrorPanel).exists()).toBeFalsy();
});
});

Expand Down
Loading

0 comments on commit 88c313e

Please sign in to comment.