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

Migrate most plugins to synchronous lifecycle #89562

Merged

Conversation

pgayvallet
Copy link
Contributor

@pgayvallet pgayvallet commented Jan 28, 2021

Summary

Part of #53268, was unblocked by #88981
Fix #71925
Fix #74395

This PR migrates most of the existing asynchronous plugins to synchronous lifecycle.

  • Change the client and server side Plugin signature to no longer accept returning promises from setup and start
  • Introduce the (deprecated) AsyncPlugin interface (same interface as the old Plugin)
  • Migrate most of the async plugins to synchronous lifecycles
  • Explicitly use AsyncPlugin instead of Plugin for plugins I couldn't migrate
  • Logs warnings in development mode for asynchronous plugins
  • Update the legacy plugin migration guide examples
  • Add missing explicit Plugin interface on some plugins + some overall cleanup

Remaining async plugins

There are only 3 2 plugins this PR does not migrate:

I will create a distinct issue to discuss about those with the owners once this PR is merged.

Checklist

@pgayvallet pgayvallet added release_note:skip Skip the PR/issue when compiling release notes v7.12.0 v8.0.0 labels Jan 29, 2021
@pgayvallet pgayvallet changed the title Migrate plugins to synchronous lifecycle Migrate most plugins to synchronous lifecycle Jan 29, 2021
Copy link
Contributor Author

@pgayvallet pgayvallet left a comment

Choose a reason for hiding this comment

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

Implementation review

Comment on lines +129 to +137
if (isPromise(startContract)) {
return startContract.then((resolvedContract) => {
this.startDependencies$.next([startContext, plugins, resolvedContract]);
return resolvedContract;
});
} else {
this.startDependencies$.next([startContext, plugins, startContract]);
return startContract;
}
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 need to dissociate promises from other return values in the plugin system, so the plugin wrapper can no longer be async. This is why I need to chain the promise to resolve the startDependencies

Comment on lines +107 to +112
if (this.coreContext.env.mode.dev) {
// eslint-disable-next-line no-console
console.log(
`Plugin ${pluginName} is using asynchronous setup lifecycle. Asynchronous plugins support will be removed in a later version.`
);
}
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Until we implement a client-side logger, we don't have any other options than just console.log the warning for client-side plugins

Comment on lines +54 to +56
private instance?:
| Plugin<TSetup, TStart, TPluginsSetup, TPluginsStart>
| AsyncPlugin<TSetup, TStart, TPluginsSetup, TPluginsStart>;
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 started by adding a EitherPlugin = Plugin | AsyncPlugin type, but as this is only a temporary measure, I think that having the explicit composite type in the few places we are using plugins is better.

Copy link
Contributor

@sebelga sebelga left a comment

Choose a reason for hiding this comment

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

ES UI changed LGTM. Thanks!

Copy link
Member

@weltenwort weltenwort left a comment

Choose a reason for hiding this comment

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

Seems to work for the infra plugin, thank you 👍

Out of curiosity, do you remember if the config semantics changes since the new platform was introduced? We used the async access to config because the config wasn't loaded early enough. A simple test shows it is now. 🤷

@pgayvallet
Copy link
Contributor Author

@weltenwort

Out of curiosity, do you remember if the config semantics changes since the new platform was introduced? We used the async access to config because the config wasn't loaded early enough

The synchronous config access API was added last week by #88981, but apart from that I don't think we changed the behavior of the context.config.create() API over the last year.

@pgayvallet
Copy link
Contributor Author

@elastic/endpoint-app-team @elastic/kibana-presentation @elastic/stack-monitoring-ui still waiting for your reviews

Copy link
Contributor

@chrisronline chrisronline left a comment

Choose a reason for hiding this comment

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

LGTM for Stack Monitoring!

@kibanamachine
Copy link
Contributor

💚 Build Succeeded

Metrics [docs]

Async chunks

Total size of all lazy-loaded chunks that will be downloaded as the user navigates the app

id before after diff
data 236.1KB 236.4KB +265.0B
fleet 759.7KB 760.0KB +265.0B
graph 1.2MB 1.2MB +265.0B
total +795.0B

Page load bundle

Size of the bundles that are downloaded on every page load. Target size is below 100kb

id before after diff
cloud 5.2KB 5.2KB -6.0B
core 466.6KB 467.7KB +1.1KB
fleet 365.9KB 365.9KB -6.0B
inspector 44.1KB 44.1KB -6.0B
licensing 14.8KB 14.8KB -6.0B
monitoring 49.5KB 49.5KB -6.0B
presentationUtil 25.9KB 25.9KB -6.0B
regionMap 19.4KB 19.4KB -6.0B
tileMap 18.0KB 18.0KB -6.0B
uptime 19.3KB 19.3KB -6.0B
urlDrilldown 42.1KB 42.4KB +265.0B
visTypeTimeseries 126.7KB 126.7KB -6.0B
visTypeVega 57.4KB 57.4KB -6.0B
visTypeVislib 36.0KB 36.0KB -6.0B
visTypeXy 46.5KB 46.5KB -6.0B
visualize 28.8KB 28.8KB -6.0B
total +1.3KB

History

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

@pgayvallet pgayvallet merged commit 3b3327d into elastic:master Feb 8, 2021
pgayvallet added a commit to pgayvallet/kibana that referenced this pull request Feb 8, 2021
* first pass

* migrate more plugins

* migrate yet more plugins

* more oss plugins

* fix test file

* change Plugin signature on the client-side too

* fix test types

* migrate OSS client-side plugins

* migrate OSS client-side test plugins

* migrate xpack client-side plugins

* revert fix attempt on fleet plugin

* fix presentation start signature

* fix yet another signature

* add warnings for server-side async plugins in dev mode

* remove unused import

* fix isPromise

* Add client-side deprecations

* update migration examples

* update generated doc

* fix xpack unit tests

* nit

* (will be reverted) explicitly await for license to be ready in the auth hook

* Revert "(will be reverted) explicitly await for license to be ready in the auth hook"

This reverts commit fdf73fe

* restore await on on promise contracts

* Revert "(will be reverted) explicitly await for license to be ready in the auth hook"

This reverts commit fdf73fe

* Revert "restore await on on promise contracts"

This reverts commit c5f2fe5

* add delay before starting tests in FTR

* update deprecation ts doc

* add explicit contract for monitoring setup

* migrate monitoring plugin to sync

* change plugin timeout to 10sec

* use delay instead of silence
# Conflicts:
#	x-pack/plugins/xpack_legacy/server/plugin.ts
pgayvallet added a commit that referenced this pull request Feb 8, 2021
* Migrate most plugins to synchronous lifecycle (#89562)

* first pass

* migrate more plugins

* migrate yet more plugins

* more oss plugins

* fix test file

* change Plugin signature on the client-side too

* fix test types

* migrate OSS client-side plugins

* migrate OSS client-side test plugins

* migrate xpack client-side plugins

* revert fix attempt on fleet plugin

* fix presentation start signature

* fix yet another signature

* add warnings for server-side async plugins in dev mode

* remove unused import

* fix isPromise

* Add client-side deprecations

* update migration examples

* update generated doc

* fix xpack unit tests

* nit

* (will be reverted) explicitly await for license to be ready in the auth hook

* Revert "(will be reverted) explicitly await for license to be ready in the auth hook"

This reverts commit fdf73fe

* restore await on on promise contracts

* Revert "(will be reverted) explicitly await for license to be ready in the auth hook"

This reverts commit fdf73fe

* Revert "restore await on on promise contracts"

This reverts commit c5f2fe5

* add delay before starting tests in FTR

* update deprecation ts doc

* add explicit contract for monitoring setup

* migrate monitoring plugin to sync

* change plugin timeout to 10sec

* use delay instead of silence
# Conflicts:
#	x-pack/plugins/xpack_legacy/server/plugin.ts

* fix mock
gmmorris added a commit to gmmorris/kibana that referenced this pull request Feb 8, 2021
* master: (55 commits)
  [APM-UI][E2E] use githubNotify step (elastic#90514)
  [APM] Export ProcessorEvent type (elastic#90540)
  [Lens] Retain column config (elastic#90048)
  [Data Table] Add unit tests (elastic#90173)
  Migrate most plugins to synchronous lifecycle (elastic#89562)
  skip flaky suite (elastic#90555)
  skip flaky suite (elastic#64473)
  [actions] improve email action doc (elastic#90020)
  [Fleet] Support Fleet server system indices (elastic#89372)
  skip flaky suite (elastic#90552)
  Bump immer dependencies (elastic#90267)
  Unrevert "Migrations v2: don't auto-create indices + FTR/esArchiver support (elastic#85778)" (elastic#89992)
  [Search Sessions] Use sync config (elastic#90138)
  chore(NA): add safe guard to remove bazelisk from yarn global at bootstrap (elastic#90538)
  [test] Await retry.waitFor (elastic#90456)
  chore(NA): integrate build buddy with our bazel setup and remote cache for ci (elastic#90116)
  Skip failing suite (elastic#90526)
  [Fleet] Fix incorrect conversion of string to numeric values in agent YAML (elastic#90371)
  [Docs] Update reporting troubleshooting for arm rhel/centos (elastic#90385)
  chore(NA): build bazel projects all at once in the distributable build process (elastic#90328)
  ...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
chore Feature:New Platform release_note:skip Skip the PR/issue when compiling release notes Team:APM All issues that need APM UI Team support Team:Core Core services & architecture: plugins, logging, config, saved objects, http, ES client, i18n, etc Team:Fleet Team label for Observability Data Collection Fleet team Team:Uptime - DEPRECATED Synthetics & RUM sub-team of Application Observability v7.12.0 v8.0.0
Projects
None yet