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

Make Core interfaces exposed to LP plugins consistent with NP plugins #47074

Merged
merged 6 commits into from
Oct 7, 2019

Conversation

joshdover
Copy link
Contributor

@joshdover joshdover commented Oct 1, 2019

Summary

While working on cleaning up some type definitions, I noticed that we're not expose the same interface to the Legacy platform that will be available to New Platform plugins.

The main issue is the difference between HttpServiceSetup and CoreSetup['http']. In the internal variant, we require a pluginOpaqueId argument to some functions (eg. createRouter, registerRouteContext).

This changes that by making sure we're expose CoreSetup and CoreStart rather than the internal variants of those interfaces by building an object using a fake opaqueId that the LegacyService generates.

Risks

By using a single opaqueId for all legacy code, context providers registered by legacy code will be available to all legacy plugins. This does create a leak across plugin boundaries where legacy plugins could depend on other legacy code without realizing it.

I don't think this risk is too bad because:

  1. New Platform plugins are still insulated from this problem since none of them can depend on the Legacy Platform.
  2. Legacy plugins can already do this inadvertently via server.ext or via uiExports, so this doesn't quite make the problem worse, and it doesn't leak that problem to New Platform plugins.
  3. It should be pretty obvious that if you're accessing context values that are not in the context.core object, you should be depending on plugins that actually provide this value.

Further improvements

We could take this one step further and solve a different problem: legacy plugins cannot currently get context registered by New Platform plugins. We could solve this by defining the fake "legacy plugin" as dependent on all other plugins in the system.

@elastic/kibana-platform what do y'all think? We will do this in a future PR.

Checklist

Use strikethroughs to remove checklist items you don't feel are applicable to this PR.

For maintainers

@elasticmachine
Copy link
Contributor

💔 Build Failed

@elasticmachine
Copy link
Contributor

💔 Build Failed

@elasticmachine
Copy link
Contributor

💔 Build Failed

@joshdover joshdover force-pushed the np/legacy-core-contracts branch 2 times, most recently from c1ab169 to 71d4ddb Compare October 1, 2019 21:18
@elasticmachine
Copy link
Contributor

💔 Build Failed

@joshdover joshdover changed the title Make core interfaces exposed to legacy platform consistent Make Core interfaces exposed to LP plugins consistent with NP plugins Oct 1, 2019
@joshdover joshdover added Feature:New Platform release_note:skip Skip the PR/issue when compiling release notes Team:Core Core services & architecture: plugins, logging, config, saved objects, http, ES client, i18n, etc v7.5.0 labels Oct 1, 2019
@joshdover joshdover marked this pull request as ready for review October 1, 2019 23:21
@joshdover joshdover requested a review from a team October 1, 2019 23:21
@joshdover joshdover requested review from a team as code owners October 1, 2019 23:21
@elasticmachine
Copy link
Contributor

💔 Build Failed

Copy link
Member

@jgowdyelastic jgowdyelastic left a comment

Choose a reason for hiding this comment

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

ML changes LGTM

@rudolf
Copy link
Contributor

rudolf commented Oct 2, 2019

We could take this one step further and solve a different problem: legacy plugins cannot currently get context registered by New Platform plugins. We could solve this by defining the fake "legacy plugin" as dependent on all other plugins in the system.

I like this idea. It's similar to how kbnServer.newPlatform.setup.plugins gives legacy plugins access to all NP plugins in a way that simulates a dependency on them.

Would this solve any immediate problems? The utility of this is somewhat limited in that it requires NP plugins which have registered context and legacy plugins who use the NP router.

@joshdover
Copy link
Contributor Author

joshdover commented Oct 2, 2019

Would this solve any immediate problems? The utility of this is somewhat limited in that it requires NP plugins which have registered context and legacy plugins who use the NP router.

One of the things being worked on is the "search" plugin which provides different search strategies to plugins. This is a new plugin that will replace courier, and the primary way plugins would consume it would be via request and mount contexts.

Going with this option would give legacy plugins a way to start consuming these without having to move code over to NP yet.

I am going to move forward with this idea, but keep it in a separate PR.

@elasticmachine
Copy link
Contributor

💔 Build Failed

@joshdover
Copy link
Contributor Author

@restrry The integration tests are failing on this line:

https://github.com/joshdover/kibana/blob/c1ca31a6f36f39237c4564bcee9a6998e58953a0/src/core/server/http/integration_tests/core_services.test.ts#L152

          handler: kbnServer.newPlatform.setup.core.http.auth.get,

Do you know if the legacy platform actually needs this still?

@mshustov
Copy link
Contributor

mshustov commented Oct 4, 2019

@joshdover there are 2 problems:

  • http.auth API is not exposed to NP plugins, because we haven't finalized it yet
  • typings are broken and don't warn you that platform doesn't expose this API

I sent fix in you repo joshdover#29

@joshdover
Copy link
Contributor Author

@restrry You're too kind, thanks!

@elasticmachine
Copy link
Contributor

💚 Build Succeeded

@joshdover
Copy link
Contributor Author

@elasticmachine merge upstream

@elasticmachine
Copy link
Contributor

💚 Build Succeeded

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Feature:New Platform release_note:skip Skip the PR/issue when compiling release notes Team:Core Core services & architecture: plugins, logging, config, saved objects, http, ES client, i18n, etc v7.5.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants