Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add timeouts and setup enforcement for custom plugins statuses #77965

Merged
merged 15 commits into from
Jun 23, 2021

Conversation

joshdover
Copy link
Contributor

@joshdover joshdover commented Sep 18, 2020

Summary

Closes #101049

Introduces two changes to make Core's StatusService more resilient to issues caused by custom plugin status checks:

  • Enforces that core.status.set cannot be called after setup to help encourage plugins to register an observable early, ideally with an initial status
  • Adds a timeout to custom status Observables that defaults to unavailable if a status check is not emitted by a plugin within 30s.

This should help avoid problems like those found with the alerting and task_manager plugins in #101778

Plugin API Changes

Custom status checks registered by plugins on the core.status.set API must now emit a value within 30s or they will timeout to an unavailable status.

Checklist

Delete any items that are not applicable to this PR.

For maintainers

@joshdover joshdover force-pushed the status/timeouts-and-errors branch from e860142 to 7b728e7 Compare June 12, 2021 14:47
@joshdover joshdover changed the title Add timeout and error handling to custom plugins statuses Add timeouts and setup enforcement for custom plugins statuses Jun 12, 2021
@@ -231,6 +253,75 @@ describe('PluginStatusService', () => {
{ a: { level: ServiceStatusLevels.available, summary: 'a available' } },
]);
});

it('updates when a plugin status observable emits', async () => {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This test case was actually missing, even though it's the most likely behavior from a plugin.

@joshdover joshdover force-pushed the status/timeouts-and-errors branch 2 times, most recently from 8747772 to ebda07b Compare June 15, 2021 10:51
@joshdover joshdover added release_note:plugin_api_changes Contains a Plugin API changes section for the breaking plugin API changes section. Team:Core Core services & architecture: plugins, logging, config, saved objects, http, ES client, i18n, etc v7.14.0 v8.0.0 labels Jun 15, 2021
@joshdover joshdover marked this pull request as ready for review June 15, 2021 10:51
@joshdover joshdover requested a review from a team as a code owner June 15, 2021 10:51
@elasticmachine
Copy link
Contributor

Pinging @elastic/kibana-core (Team:Core)

@joshdover joshdover added the auto-backport Deprecated - use backport:version if exact versions are needed label Jun 15, 2021
@joshdover joshdover enabled auto-merge (squash) June 15, 2021 10:52
@joshdover joshdover disabled auto-merge June 15, 2021 12:44
@joshdover joshdover marked this pull request as draft June 17, 2021 12:22
@joshdover
Copy link
Contributor Author

Setting back to draft until #102108 is done since it affects this PR

@joshdover joshdover force-pushed the status/timeouts-and-errors branch from ebda07b to c3d8571 Compare June 17, 2021 18:26
@joshdover joshdover marked this pull request as ready for review June 17, 2021 18:26
@joshdover joshdover enabled auto-merge (squash) June 17, 2021 18:26
@joshdover joshdover force-pushed the status/timeouts-and-errors branch 3 times, most recently from 1657110 to e5239ff Compare June 21, 2021 12:27
@joshdover joshdover force-pushed the status/timeouts-and-errors branch from e5239ff to 1e9a557 Compare June 21, 2021 16:53
@joshdover joshdover requested a review from a team as a code owner June 21, 2021 16:53
Copy link
Contributor

@spalger spalger left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

New plugin dir changes look good

@joshdover joshdover force-pushed the status/timeouts-and-errors branch from 69e12c7 to 4098de2 Compare June 22, 2021 11:59
@joshdover
Copy link
Contributor Author

@elasticmachine retest

@joshdover
Copy link
Contributor Author

jenkins, test this

@kibanamachine
Copy link
Contributor

💚 Backport successful

Status Branch Result
7.x

This backport PR will be merged automatically after passing CI.

kibanamachine added a commit that referenced this pull request Jun 23, 2021
@kibanamachine
Copy link
Contributor

kibanamachine commented Jul 7, 2021

💔 Build Failed

Failed CI Steps


Test Failures

Kibana Pipeline / general / X-Pack API Integration Tests.x-pack/test/api_integration/apis/management/index_lifecycle_management/policies·js.apis management index lifecycle management policies list should have a default policy to manage the Watcher history indices

Link to Jenkins

Standard Out

Failed Tests Reporter:
  - Test has failed 3 times on tracked branches: https://github.com/elastic/kibana/issues/41237

[00:00:00]       │
[00:00:00]         └-: apis
[00:00:00]           └-> "before all" hook in "apis"
[00:05:47]           └-: management
[00:05:47]             └-> "before all" hook in "management"
[00:06:11]             └-: index lifecycle management
[00:06:11]               └-> "before all" hook in "index lifecycle management"
[00:06:11]               └-: policies
[00:06:11]                 └-> "before all" hook in "policies"
[00:06:11]                 └-: list
[00:06:11]                   └-> "before all" hook for "should have a default policy to manage the Watcher history indices"
[00:06:11]                   └-> should have a default policy to manage the Watcher history indices
[00:06:11]                     └-> "before each" hook: global before each for "should have a default policy to manage the Watcher history indices"
[00:06:11]                     └- ✖ fail: apis management index lifecycle management policies list should have a default policy to manage the Watcher history indices
[00:06:11]                     │       Error: expected { version: 1,
[00:06:11]                     │   modified_date: '2019-04-30T14:30:00.000Z',
[00:06:11]                     │   policy: { phases: { delete: [Object] } },
[00:06:11]                     │   in_use_by: 
[00:06:11]                     │    { indices: [],
[00:06:11]                     │      data_streams: [],
[00:06:11]                     │      composable_templates: [ '.watch-history-14' ] },
[00:06:11]                     │   name: 'watch-history-ilm-policy' } to sort of equal { version: 1,
[00:06:11]                     │   modified_date: '2019-04-30T14:30:00.000Z',
[00:06:11]                     │   policy: { phases: { delete: [Object] } },
[00:06:11]                     │   name: 'watch-history-ilm-policy' }
[00:06:11]                     │       + expected - actual
[00:06:11]                     │ 
[00:06:11]                     │        {
[00:06:11]                     │       -  "in_use_by": {
[00:06:11]                     │       -    "composable_templates": [
[00:06:11]                     │       -      ".watch-history-14"
[00:06:11]                     │       -    ]
[00:06:11]                     │       -    "data_streams": []
[00:06:11]                     │       -    "indices": []
[00:06:11]                     │       -  }
[00:06:11]                     │          "modified_date": "2019-04-30T14:30:00.000Z"
[00:06:11]                     │          "name": "watch-history-ilm-policy"
[00:06:11]                     │          "policy": {
[00:06:11]                     │            "phases": {
[00:06:11]                     │       
[00:06:11]                     │       at Assertion.assert (/dev/shm/workspace/parallel/19/kibana/node_modules/@kbn/expect/expect.js:100:11)
[00:06:11]                     │       at Assertion.eql (/dev/shm/workspace/parallel/19/kibana/node_modules/@kbn/expect/expect.js:244:8)
[00:06:11]                     │       at Context.<anonymous> (test/api_integration/apis/management/index_lifecycle_management/policies.js:50:27)
[00:06:11]                     │       at Object.apply (/dev/shm/workspace/parallel/19/kibana/node_modules/@kbn/test/src/functional_test_runner/lib/mocha/wrap_function.js:73:16)
[00:06:11]                     │ 
[00:06:11]                     │ 

Stack Trace

Error: expected { version: 1,
  modified_date: '2019-04-30T14:30:00.000Z',
  policy: { phases: { delete: [Object] } },
  in_use_by: 
   { indices: [],
     data_streams: [],
     composable_templates: [ '.watch-history-14' ] },
  name: 'watch-history-ilm-policy' } to sort of equal { version: 1,
  modified_date: '2019-04-30T14:30:00.000Z',
  policy: { phases: { delete: [Object] } },
  name: 'watch-history-ilm-policy' }
    at Assertion.assert (/dev/shm/workspace/parallel/19/kibana/node_modules/@kbn/expect/expect.js:100:11)
    at Assertion.eql (/dev/shm/workspace/parallel/19/kibana/node_modules/@kbn/expect/expect.js:244:8)
    at Context.<anonymous> (test/api_integration/apis/management/index_lifecycle_management/policies.js:50:27)
    at Object.apply (/dev/shm/workspace/parallel/19/kibana/node_modules/@kbn/test/src/functional_test_runner/lib/mocha/wrap_function.js:73:16) {
  actual: '{\n' +
    '  "in_use_by": {\n' +
    '    "composable_templates": [\n' +
    '      ".watch-history-14"\n' +
    '    ]\n' +
    '    "data_streams": []\n' +
    '    "indices": []\n' +
    '  }\n' +
    '  "modified_date": "2019-04-30T14:30:00.000Z"\n' +
    '  "name": "watch-history-ilm-policy"\n' +
    '  "policy": {\n' +
    '    "phases": {\n' +
    '      "delete": {\n' +
    '        "actions": {\n' +
    '          "delete": {\n' +
    '            "delete_searchable_snapshot": true\n' +
    '          }\n' +
    '        }\n' +
    '        "min_age": "7d"\n' +
    '      }\n' +
    '    }\n' +
    '  }\n' +
    '  "version": 1\n' +
    '}',
  expected: '{\n' +
    '  "modified_date": "2019-04-30T14:30:00.000Z"\n' +
    '  "name": "watch-history-ilm-policy"\n' +
    '  "policy": {\n' +
    '    "phases": {\n' +
    '      "delete": {\n' +
    '        "actions": {\n' +
    '          "delete": {\n' +
    '            "delete_searchable_snapshot": true\n' +
    '          }\n' +
    '        }\n' +
    '        "min_age": "7d"\n' +
    '      }\n' +
    '    }\n' +
    '  }\n' +
    '  "version": 1\n' +
    '}',
  showDiff: true
}

Kibana Pipeline / general / X-Pack API Integration Tests.x-pack/test/api_integration/apis/management/index_lifecycle_management/policies·js.apis management index lifecycle management policies list should have a default policy to manage the Watcher history indices

Link to Jenkins

Standard Out

Failed Tests Reporter:
  - Test has failed 3 times on tracked branches: https://github.com/elastic/kibana/issues/41237

[00:00:00]       │
[00:00:00]         │ info [o.e.c.r.a.AllocationService] [kibana-ci-immutable-centos-tests-xxl-1625695132627315867] current.health="GREEN" message="Cluster health status changed from [YELLOW] to [GREEN] (reason: [shards started [[.ds-ilm-history-5-2021.07.07-000001][0]]])." previous.health="YELLOW" reason="shards started [[.ds-ilm-history-5-2021.07.07-000001][0]]"
[00:00:00]         │ info [o.e.x.i.IndexLifecycleTransition] [kibana-ci-immutable-centos-tests-xxl-1625695132627315867] moving index [.ds-ilm-history-5-2021.07.07-000001] from [null] to [{"phase":"new","action":"complete","name":"complete"}] in policy [ilm-history-ilm-policy]
[00:00:00]         │ info [o.e.x.i.IndexLifecycleTransition] [kibana-ci-immutable-centos-tests-xxl-1625695132627315867] moving index [.ds-ilm-history-5-2021.07.07-000001] from [{"phase":"new","action":"complete","name":"complete"}] to [{"phase":"hot","action":"unfollow","name":"branch-check-unfollow-prerequisites"}] in policy [ilm-history-ilm-policy]
[00:00:00]         │ info [o.e.x.i.IndexLifecycleTransition] [kibana-ci-immutable-centos-tests-xxl-1625695132627315867] moving index [.ds-ilm-history-5-2021.07.07-000001] from [{"phase":"hot","action":"unfollow","name":"branch-check-unfollow-prerequisites"}] to [{"phase":"hot","action":"rollover","name":"check-rollover-ready"}] in policy [ilm-history-ilm-policy]
[00:00:00]         └-: apis
[00:00:00]           └-> "before all" hook in "apis"
[00:05:54]           └-: management
[00:05:54]             └-> "before all" hook in "management"
[00:06:18]             └-: index lifecycle management
[00:06:18]               └-> "before all" hook in "index lifecycle management"
[00:06:18]               └-: policies
[00:06:18]                 └-> "before all" hook in "policies"
[00:06:18]                 └-: list
[00:06:18]                   └-> "before all" hook for "should have a default policy to manage the Watcher history indices"
[00:06:18]                   └-> should have a default policy to manage the Watcher history indices
[00:06:18]                     └-> "before each" hook: global before each for "should have a default policy to manage the Watcher history indices"
[00:06:18]                     └- ✖ fail: apis management index lifecycle management policies list should have a default policy to manage the Watcher history indices
[00:06:18]                     │       Error: expected { version: 1,
[00:06:18]                     │   modified_date: '2019-04-30T14:30:00.000Z',
[00:06:18]                     │   policy: { phases: { delete: [Object] } },
[00:06:18]                     │   in_use_by: 
[00:06:18]                     │    { indices: [],
[00:06:18]                     │      data_streams: [],
[00:06:18]                     │      composable_templates: [ '.watch-history-14' ] },
[00:06:18]                     │   name: 'watch-history-ilm-policy' } to sort of equal { version: 1,
[00:06:18]                     │   modified_date: '2019-04-30T14:30:00.000Z',
[00:06:18]                     │   policy: { phases: { delete: [Object] } },
[00:06:18]                     │   name: 'watch-history-ilm-policy' }
[00:06:18]                     │       + expected - actual
[00:06:18]                     │ 
[00:06:18]                     │        {
[00:06:18]                     │       -  "in_use_by": {
[00:06:18]                     │       -    "composable_templates": [
[00:06:18]                     │       -      ".watch-history-14"
[00:06:18]                     │       -    ]
[00:06:18]                     │       -    "data_streams": []
[00:06:18]                     │       -    "indices": []
[00:06:18]                     │       -  }
[00:06:18]                     │          "modified_date": "2019-04-30T14:30:00.000Z"
[00:06:18]                     │          "name": "watch-history-ilm-policy"
[00:06:18]                     │          "policy": {
[00:06:18]                     │            "phases": {
[00:06:18]                     │       
[00:06:18]                     │       at Assertion.assert (/dev/shm/workspace/parallel/19/kibana/node_modules/@kbn/expect/expect.js:100:11)
[00:06:18]                     │       at Assertion.eql (/dev/shm/workspace/parallel/19/kibana/node_modules/@kbn/expect/expect.js:244:8)
[00:06:18]                     │       at Context.<anonymous> (test/api_integration/apis/management/index_lifecycle_management/policies.js:50:27)
[00:06:18]                     │       at Object.apply (/dev/shm/workspace/parallel/19/kibana/node_modules/@kbn/test/src/functional_test_runner/lib/mocha/wrap_function.js:73:16)
[00:06:18]                     │ 
[00:06:18]                     │ 

Stack Trace

Error: expected { version: 1,
  modified_date: '2019-04-30T14:30:00.000Z',
  policy: { phases: { delete: [Object] } },
  in_use_by: 
   { indices: [],
     data_streams: [],
     composable_templates: [ '.watch-history-14' ] },
  name: 'watch-history-ilm-policy' } to sort of equal { version: 1,
  modified_date: '2019-04-30T14:30:00.000Z',
  policy: { phases: { delete: [Object] } },
  name: 'watch-history-ilm-policy' }
    at Assertion.assert (/dev/shm/workspace/parallel/19/kibana/node_modules/@kbn/expect/expect.js:100:11)
    at Assertion.eql (/dev/shm/workspace/parallel/19/kibana/node_modules/@kbn/expect/expect.js:244:8)
    at Context.<anonymous> (test/api_integration/apis/management/index_lifecycle_management/policies.js:50:27)
    at Object.apply (/dev/shm/workspace/parallel/19/kibana/node_modules/@kbn/test/src/functional_test_runner/lib/mocha/wrap_function.js:73:16) {
  actual: '{\n' +
    '  "in_use_by": {\n' +
    '    "composable_templates": [\n' +
    '      ".watch-history-14"\n' +
    '    ]\n' +
    '    "data_streams": []\n' +
    '    "indices": []\n' +
    '  }\n' +
    '  "modified_date": "2019-04-30T14:30:00.000Z"\n' +
    '  "name": "watch-history-ilm-policy"\n' +
    '  "policy": {\n' +
    '    "phases": {\n' +
    '      "delete": {\n' +
    '        "actions": {\n' +
    '          "delete": {\n' +
    '            "delete_searchable_snapshot": true\n' +
    '          }\n' +
    '        }\n' +
    '        "min_age": "7d"\n' +
    '      }\n' +
    '    }\n' +
    '  }\n' +
    '  "version": 1\n' +
    '}',
  expected: '{\n' +
    '  "modified_date": "2019-04-30T14:30:00.000Z"\n' +
    '  "name": "watch-history-ilm-policy"\n' +
    '  "policy": {\n' +
    '    "phases": {\n' +
    '      "delete": {\n' +
    '        "actions": {\n' +
    '          "delete": {\n' +
    '            "delete_searchable_snapshot": true\n' +
    '          }\n' +
    '        }\n' +
    '        "min_age": "7d"\n' +
    '      }\n' +
    '    }\n' +
    '  }\n' +
    '  "version": 1\n' +
    '}',
  showDiff: true
}

Metrics [docs]

✅ unchanged

History

To update your PR or re-run it, just comment with:
@elasticmachine merge upstream

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
auto-backport Deprecated - use backport:version if exact versions are needed release_note:plugin_api_changes Contains a Plugin API changes section for the breaking plugin API changes section. Team:Core Core services & architecture: plugins, logging, config, saved objects, http, ES client, i18n, etc v7.14.0 v8.0.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Status API sometimes reports outdated values
6 participants