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

Stricter Setup / Start API separation #66366

Open
mshustov opened this issue May 13, 2020 · 5 comments
Open

Stricter Setup / Start API separation #66366

mshustov opened this issue May 13, 2020 · 5 comments
Labels
Feature:New Platform Meta Team:Core Core services & architecture: plugins, logging, config, saved objects, http, ES client, i18n, etc

Comments

@mshustov
Copy link
Contributor

mshustov commented May 13, 2020

From the very beginning Kibana platform uses a notion of lifecycles to separate runtime process into different stages:

  • setup - the preparatory stage. It should be used to declare cross-plugin dependencies and dependencies on the platform functionality. Kibana remains at this stage for a limited amount of time. In the future, this amount of time may be reduced to one tick.
  • start - the runtime stage. Meant to be used to perform the Kibana functionality. It's a long-running stage. Kibana is in this state most of the time while it's running.
  • stop - the teardown stage. It might be used to clean up resources and stop ongoing operations.

However, all the stages exist merely as a convention. This has led to the fact that plugins (and the platform itself) mix functionality up and provide runtime API from setup phase. As a result, when the platform decided to refactor public contracts we have realized it cannot be done due to the number of existing external dependencies.
Not the full list of the blocked tasks:

To prevent problems in the future, we are going to reinforce the separation of the lifecycle stages. Otherwise, we have to add defensive checks in the code that API can be called, which is an error-prone approach. By default API exposed from start lifecycle stage unless it's crucial to move it to the setup stage

Suggestions:

  • to move platform API meant to be used in runtime to the start phase.
  • identify plugins that can be affected by this change and create issues for code owners to refactor the public API.
  • add a tracking mechanism to monitor all the cases when API is called from a not-relevant stage.
  • fix all the problem places.
  • enforce a hard separation for API. Invoking API from another stage will throw an exception.

Child tasks:

@mshustov mshustov added discuss Team:Core Core services & architecture: plugins, logging, config, saved objects, http, ES client, i18n, etc Feature:New Platform labels May 13, 2020
@elasticmachine
Copy link
Contributor

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

@mshustov mshustov added Meta and removed discuss labels May 13, 2020
@mshustov
Copy link
Contributor Author

mshustov commented May 13, 2020

a preliminary list of changes on the server side to understand the magnitude of refactoring:

@joshdover
Copy link
Contributor

context service API

I believe this one should still be in setup since it is used to expose a context provider registry to other plugins.

@pgayvallet
Copy link
Contributor

pgayvallet commented Jun 15, 2020

all the http API except create router

We even want to move to start the lifecycle hook registrations such as registerOnPreAuth ?

@mshustov
Copy link
Contributor Author

mshustov commented Jan 28, 2022

We are going to start with logging a warning whenever lifecycle API is called outside of the current lifecycle timeframe #124039

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Feature:New Platform Meta Team:Core Core services & architecture: plugins, logging, config, saved objects, http, ES client, i18n, etc
Projects
None yet
Development

No branches or pull requests

4 participants