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 plugin status API #75819

Merged
merged 7 commits into from
Sep 1, 2020
Merged

Add plugin status API #75819

merged 7 commits into from
Sep 1, 2020

Conversation

joshdover
Copy link
Contributor

@joshdover joshdover commented Aug 24, 2020

Summary

Related to #41983

Implements the core.status.set, core.status.plugins$, and core.status.derivedStatus$ APIs as specified in RFC-0010.

I did not write any e2e tests in this PR as I thought it would be easier to write them directly against the migrated status HTTP API that I am working on in parallel.

To Do:

  • Add complete example docs to StatusServiceSetup that explains how plugin statuses work, how they are inherited, and how to customize them.

Dev Docs

Kibana Platform plugins may now read the status of their dependencies, their plugin's default status, and manually override that status as reported to the end user and on the /api/status endpoint.

class MyPlugin {
  setup(core) {
    // Override default behavior and only elevate severity when elasticsearch is not available
    core.status.set(
      core.status.core$.pipe(core => core.elasticsearch);
    );
  }
}

Checklist

Delete any items that are not applicable to this PR.

For maintainers

Comment on lines 269 to 320
Array [
Object {
"level": available,
"summary": "All services are available",
},
Object {
"level": degraded,
"summary": "[a]: This is degraded!",
},
Object {
"level": degraded,
"summary": "[2] services are degraded",
},
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 highlights a current problem with this Observable-based architecture: a single update to one plugin's status may result in many overall updates as it propagates through the dependency tree.

I plan to experiment more tomorrow with RxJS's various schedulers and debouncing utilities, but I'm not sure yet there is a great solution to this. Even if there is, we still would need to provide guidance or utilities so that plugin authors can also avoid this same issue in their custom status implementations.

Copy link
Contributor

@mshustov mshustov Aug 25, 2020

Choose a reason for hiding this comment

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

https://www.learnrxjs.io/learn-rxjs/operators/filtering/debouncetime after combineLatest? Can it be backed in the core in order not to enforce plugins to wrap it manually?

Copy link
Contributor

@pgayvallet pgayvallet Aug 25, 2020

Choose a reason for hiding this comment

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

+1 for debounce effect of some kind to the overall$ and plugins$ observables. We probably want to keep the derivedStatus$ exposed to plugins 'fresh' to avoid delay in status recomputation though?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

My goal was to avoid any time-based approach in order to make the behavior very consistent for synchronous Observable sources. I was able to get this to work using debounce with a variable number of microtasks based on the number of known observables. Seems to be working correctly! Now the observables should only emit once per macro-task.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I decided to just go with a time-based apporoach after all. Microtasks seemed like too much magic and very fragile to break. It's also easy to write a test which ends up changing the microtasks queue itself, leading to strange results in tests.

We probably want to keep the derivedStatus$ exposed to plugins 'fresh' to avoid delay in status recomputation though?

+1 to that. I am only going to debounce the overall$ and plugins$ observables

@joshdover joshdover added Feature:New Platform 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.10.0 labels Aug 25, 2020
@joshdover joshdover marked this pull request as ready for review August 25, 2020 23:01
@joshdover joshdover requested a review from a team as a code owner August 25, 2020 23:01
@elasticmachine
Copy link
Contributor

Pinging @elastic/kibana-platform (Team:Platform)

Comment on lines +44 to +48
// TODO: include URL to status page
detail: status.detail ?? `See the status page for more information`,
meta: {
affectedServices: { [serviceName]: status },
},
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Changed the summary output for when only a single service is unavailable to be more consistent with the case where more than one is unavailable.

src/core/server/status/plugins_status.ts Outdated Show resolved Hide resolved
src/core/server/status/plugins_status.ts Outdated Show resolved Hide resolved
src/core/server/status/plugins_status.ts Outdated Show resolved Hide resolved
src/core/server/status/plugins_status.test.ts Show resolved Hide resolved
src/core/server/status/plugins_status.ts Outdated Show resolved Hide resolved
src/core/server/status/status_service.test.ts Outdated Show resolved Hide resolved
// We schedule the number of microtasks expected to resolve all of the dependencies of this update.
// Waiting for this ensures that we do not emit 'partial updates' to reduce noise.
debounce(([coreStatus, pluginsStatus]) =>
waitForMicrotasks(1 + Object.keys(pluginsStatus).length)
Copy link
Contributor

Choose a reason for hiding this comment

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

does it mean that all this.pluginsStatus API consumers have to implement debouncing manually?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Now that debouncing is configured on the Observable used to wrap a plugin's dependencies (the core.status.dependencies$ Observable), I don't believe this will be a problem that "fans out" to consumers, so manual debouncing should be unnecessary.

src/core/server/status/types.ts Show resolved Hide resolved
src/core/server/status/status_service.ts Outdated Show resolved Hide resolved
src/core/server/status/plugins_status.ts Outdated Show resolved Hide resolved
src/core/server/status/status_service.test.ts Outdated Show resolved Hide resolved
@kibanamachine
Copy link
Contributor

💚 Build Succeeded

Build metrics

oss distributable file count

id value diff baseline
total 27306 +1 27305

distributable file count

id value diff baseline
total 45456 +1 45455

History

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

@joshdover joshdover merged commit 2006eca into elastic:master Sep 1, 2020
@joshdover joshdover deleted the status/plugin-api branch September 1, 2020 13:36
joshdover added a commit to joshdover/kibana that referenced this pull request Sep 1, 2020
# Conflicts:
#	rfcs/text/0010_service_status.md
joshdover added a commit that referenced this pull request Sep 1, 2020
spalger added a commit to spalger/kibana that referenced this pull request Sep 3, 2020
spalger added a commit that referenced this pull request Sep 3, 2020
@joshdover joshdover mentioned this pull request Sep 3, 2020
7 tasks
spalger pushed a commit that referenced this pull request Sep 4, 2020
Co-authored-by: spalger <[email protected]>
# Conflicts:
#	rfcs/text/0010_service_status.md
jloleysens added a commit to jloleysens/kibana that referenced this pull request Sep 4, 2020
…rok/new-patterns-component-use-array

* 'master' of github.com:elastic/kibana: (75 commits)
  Remove legacy ui-apps-mixin (elastic#76604)
  remove unused test_utils (elastic#76528)
  [ML] Functional tests - add UI permission tests (elastic#76368)
  [APM] @ts-error -> @ts-expect-error (elastic#76492)
  [APM] Avoid negative offset for error marker on timeline (elastic#76638)
  [Reporting] rename interfaces to align with task manager integration (elastic#76716)
  Revert back ESO migration for alerting, added try/catch logic to avoid failing Kibana on start (elastic#76220)
  Test reverting "Add plugin status API (elastic#75819)" (elastic#76707)
  [Security Solution][Detections] Removes ML Job Settings SIEM copy and fixes link to ML app for creating custom jobs (elastic#76595)
  [Maps] remove region/coordinate-maps visualizations from sample data (elastic#76399)
  [DOCS] Dashboard-first docs refresh (elastic#76194)
  Updated ServiceNow description in docs and actions management UI to contains correct info (elastic#76344)
  [DOCS] Identifies cloud settings in reporting (elastic#76691)
  [Security Solution] Refactor timeline details to use search strategy (elastic#75591)
  es-archiver: Drop invalid index settings, support --query flag  (elastic#76522)
  [DOCS] Identifies graph settings available on cloud (elastic#76661)
  Add more info about a11y tests (elastic#76045)
  [data.search.SearchSource] Remove legacy ES client APIs. (elastic#75943)
  [release notes] automatically retry on Github API 5xx errors (elastic#76447)
  [es_ui_shared] Fix eslint exhaustive deps rule (elastic#76392)
  ...
joshdover added a commit to joshdover/kibana that referenced this pull request Sep 9, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Feature:New Platform release_note:plugin_api_changes Contains a Plugin API changes section for the breaking plugin API changes section. reverted Team:Core Core services & architecture: plugins, logging, config, saved objects, http, ES client, i18n, etc v7.10.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants