-
Notifications
You must be signed in to change notification settings - Fork 8.3k
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
implement "plugin" package type #149370
implement "plugin" package type #149370
Conversation
Pinging @elastic/kibana-operations (Team:Operations) |
@lukeelmers your input here would help a lot! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I left a few questions and recommend getting input from other team members on test coverage but it seems to be good. I'll give it a tentative LGTM. There are still a few days to follow up with changes if needed.
...re/plugins/core-plugins-server-internal/src/discovery/plugin_manifest_from_plugin_package.ts
Show resolved
Hide resolved
...re/plugins/core-plugins-server-internal/src/discovery/plugin_manifest_from_plugin_package.ts
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Tentative LGTM pending questions and test-coverage input from other team members.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To be perfectly honest, I'm still not sure to understand why exactly we want to change the plugin scanning system to be based on our generated plugin list instead of just filesystem scan as it's done today.
I get the fact that it's more performant, given that packages can be 'anywhere' and that therefore the plugin discovery system would take more time if it was only based on FS scan, but still, having the implementation diverging between 3rd parties (and test?) plugins and our internal ones feels somewhat wrong to me.
Now, this is just my gut feeling, I don't have any strong argument against this PR's changes.
A few questions and remarks that I'd like covered before the merge though:
import { PluginType } from '@kbn/core-base-common'; | ||
import { pluginManifestFromPluginPackage } from './plugin_manifest_from_plugin_package'; | ||
|
||
const kibanaVersion = `1.${Math.round(10 * Math.random())}.1`; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
NIT: rand
in tests is bad, m'kay?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lol, fine, want me to just hard-code a version here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, given we had surprises in the past when using the current version, having an hardcoded one seems the best compromise to me
id: manifest.plugin.id, | ||
version: '1.0.0', | ||
enabledOnAnonymousPages: manifest.plugin.enabledOnAnonymousPages, | ||
serviceFolders: manifest.serviceFolders, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What are serviceFolders
exactly? I saw the documentation on this property later in the PR, but still not sure to get it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pretty sure they were added to the documentation system for core specifically so that core/server
and core/public
were separate documentation sections. I'm not totally clear what it actually does, but I'm just maintaining support for it.
const pluginPkgDiscovery$ = from(coreContext.env.repoPackages ?? EMPTY).pipe( | ||
filter( | ||
getPluginPackagesFilter({ | ||
oss: coreContext.env.cliArgs.oss, | ||
examples: coreContext.env.cliArgs.runExamples, | ||
paths: config.additionalPluginPaths, | ||
parentDirs: config.pluginSearchPaths, | ||
}) | ||
), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a fundamental change. The associated test file will have to be adapted accordingly.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
const manifest = pluginManifestFromPluginPackage( | ||
coreContext.env.packageInfo.version, | ||
pkg.manifest | ||
); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's still unclear to me how to define multi-zone (browser+server) plugins with this package approach? Is it as simple as creating a package with a server
and client
sub folders? I assume so, given the PR remove the distinction with a single plugin
package type, but I wanted to confirm it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's based on the plugin.server
and plugin.browser
properties in kibana.jsonc
. They're both required properties in the manifest.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry if my question was unclear, let me rephrase: can we still define plugins having both server
and client
parts with the new system?
}) | ||
); | ||
|
||
const discoveryResults$ = merge(fsDiscovery$, pluginPkgDiscovery$).pipe(shareReplay()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
merge(fsDiscovery$, pluginPkgDiscovery$)
I feel like we should be checking for duplicated from the two sources somehow here, unless we're adamant there's no risk of plugins being scanned by both (fs+package), wdyt?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The filesystem scanning only finds legacy plugins with kibana.json
files, and the package scanning only finds packages with kibana.jsonc
files. fsDiscovery$
won't ever produce duplicate values, though I'm find adding a distinct operator here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
My naive question was: what about a folder with both kibana.json
and kibana.jsonc
for the same plugin?
@@ -64,6 +66,8 @@ export class Env { | |||
public readonly logDir: string; | |||
/** @internal */ | |||
public readonly pluginSearchPaths: readonly string[]; | |||
/** @internal */ | |||
public readonly repoPackages?: readonly Package[]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
NIT: update unit tests accordingly
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, the locations of packages is flexible, and the manifest approach to package discovery (listing dirs to search somewhere) is limiting and annoying for normal devs. Being able to put packages anywhere is a really good DX and worth it IMO, but we can't just scan every file in the repo to find all the kibana.jsonc files. We do this in bootstrap because we know we're in a git repo and can list all the files very efficiently, and we do it in the build process because we have the list of packages we are adding to the build. Either way, this approach brings a lot of consistency to many other operations, which is why this feels so good to me. Third-party plugins might also get a similar treatment, but we just haven't solved that problem yet. It should be really simple to add third-party packages to the standard package list, we just have to figure out the semantics around that, and then we can deprecate the old file-scanning code and remove it at some point. |
…bana into implement/plugin-package-type
💚 Build Succeeded
Metrics [docs]Public APIs missing comments
History
To update your PR or re-run it, just comment with: |
This PR updates the core discovery logic to support loading plugins from packages. This logic is additive, so that the existing plugins in the repo and third-party plugins can continue to be loaded via the existing mechanism, but with elastic#148130 we will be automatically migrating all plugins in the repo to packages, which will use this logic. The logic is already in-use in that PR, and was developed there, but extracted here for easier review. The logic is relatively simple, where a list of packages in the repo are attached to the core `Env` and then filtered by core before converting all plugin packages to `PluginWrapper`. The `PluginWrapper` still exposes the plugin manifest to the rest of the code, and it is used in many places, so rather than making changes to the `PluginWrapper` I'm faking a legacy plugin manifest with the plugin package manifest. @elastic/kibana-core: I'm going to need some help identifying what we need to get test coverage for. This is a pretty simple addition to the core IMO, and if it didn't work then nothing would work, so I'm pretty confident in it, but would still appreciate your feedback.
Fixes #149344 This PR migrates all plugins to packages automatically. It does this using `node scripts/lint_packages` to automatically migrate `kibana.json` files to `kibana.jsonc` files. By doing this automatically we can simplify many build and testing procedures to only support packages, and not both "packages" and "synthetic packages" (basically pointers to plugins). The majority of changes are in operations related code, so we'll be having operations review this before marking it ready for review. The vast majority of the code owners are simply pinged because we deleted all `kibana.json` files and replaced them with `kibana.jsonc` files, so we plan on leaving the PR ready-for-review for about 24 hours before merging (after feature freeze), assuming we don't have any blockers (especially from @elastic/kibana-core since there are a few core specific changes, though the majority were handled in #149370). --------- Co-authored-by: kibanamachine <[email protected]>
Fixes elastic#149344 This PR migrates all plugins to packages automatically. It does this using `node scripts/lint_packages` to automatically migrate `kibana.json` files to `kibana.jsonc` files. By doing this automatically we can simplify many build and testing procedures to only support packages, and not both "packages" and "synthetic packages" (basically pointers to plugins). The majority of changes are in operations related code, so we'll be having operations review this before marking it ready for review. The vast majority of the code owners are simply pinged because we deleted all `kibana.json` files and replaced them with `kibana.jsonc` files, so we plan on leaving the PR ready-for-review for about 24 hours before merging (after feature freeze), assuming we don't have any blockers (especially from @elastic/kibana-core since there are a few core specific changes, though the majority were handled in elastic#149370). --------- Co-authored-by: kibanamachine <[email protected]> (cherry picked from commit 1b85815) # Conflicts: # .github/CODEOWNERS # src/dev/build/tasks/bundle_fleet_packages.ts # src/dev/tsconfig.json # yarn.lock
# Backport This will backport the following commits from `main` to `8.7`: - [[packages] migrate all plugins to packages (#148130)](#148130) <!--- Backport version: 8.9.7 --> ### Questions ? Please refer to the [Backport tool documentation](https://github.com/sqren/backport) <!--BACKPORT [{"author":{"name":"Spencer","email":"[email protected]"},"sourceCommit":{"committedDate":"2023-02-09T03:06:50Z","message":"[packages] migrate all plugins to packages (#148130)\n\nFixes https://github.com/elastic/kibana/issues/149344\r\n\r\nThis PR migrates all plugins to packages automatically. It does this\r\nusing `node scripts/lint_packages` to automatically migrate\r\n`kibana.json` files to `kibana.jsonc` files. By doing this automatically\r\nwe can simplify many build and testing procedures to only support\r\npackages, and not both \"packages\" and \"synthetic packages\" (basically\r\npointers to plugins).\r\n\r\nThe majority of changes are in operations related code, so we'll be\r\nhaving operations review this before marking it ready for review. The\r\nvast majority of the code owners are simply pinged because we deleted\r\nall `kibana.json` files and replaced them with `kibana.jsonc` files, so\r\nwe plan on leaving the PR ready-for-review for about 24 hours before\r\nmerging (after feature freeze), assuming we don't have any blockers\r\n(especially from @elastic/kibana-core since there are a few core\r\nspecific changes, though the majority were handled in #149370).\r\n\r\n---------\r\n\r\nCo-authored-by: kibanamachine <[email protected]>","sha":"1b8581540295fde746dae6b4a09d74fb5821bfef","branchLabelMapping":{"^v8.8.0$":"main","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["Team:Operations","release_note:skip","backport:skip","v8.8.0"],"number":148130,"url":"https://github.com/elastic/kibana/pull/148130","mergeCommit":{"message":"[packages] migrate all plugins to packages (#148130)\n\nFixes https://github.com/elastic/kibana/issues/149344\r\n\r\nThis PR migrates all plugins to packages automatically. It does this\r\nusing `node scripts/lint_packages` to automatically migrate\r\n`kibana.json` files to `kibana.jsonc` files. By doing this automatically\r\nwe can simplify many build and testing procedures to only support\r\npackages, and not both \"packages\" and \"synthetic packages\" (basically\r\npointers to plugins).\r\n\r\nThe majority of changes are in operations related code, so we'll be\r\nhaving operations review this before marking it ready for review. The\r\nvast majority of the code owners are simply pinged because we deleted\r\nall `kibana.json` files and replaced them with `kibana.jsonc` files, so\r\nwe plan on leaving the PR ready-for-review for about 24 hours before\r\nmerging (after feature freeze), assuming we don't have any blockers\r\n(especially from @elastic/kibana-core since there are a few core\r\nspecific changes, though the majority were handled in #149370).\r\n\r\n---------\r\n\r\nCo-authored-by: kibanamachine <[email protected]>","sha":"1b8581540295fde746dae6b4a09d74fb5821bfef"}},"sourceBranch":"main","suggestedTargetBranches":[],"targetPullRequestStates":[{"branch":"main","label":"v8.8.0","labelRegex":"^v8.8.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/148130","number":148130,"mergeCommit":{"message":"[packages] migrate all plugins to packages (#148130)\n\nFixes https://github.com/elastic/kibana/issues/149344\r\n\r\nThis PR migrates all plugins to packages automatically. It does this\r\nusing `node scripts/lint_packages` to automatically migrate\r\n`kibana.json` files to `kibana.jsonc` files. By doing this automatically\r\nwe can simplify many build and testing procedures to only support\r\npackages, and not both \"packages\" and \"synthetic packages\" (basically\r\npointers to plugins).\r\n\r\nThe majority of changes are in operations related code, so we'll be\r\nhaving operations review this before marking it ready for review. The\r\nvast majority of the code owners are simply pinged because we deleted\r\nall `kibana.json` files and replaced them with `kibana.jsonc` files, so\r\nwe plan on leaving the PR ready-for-review for about 24 hours before\r\nmerging (after feature freeze), assuming we don't have any blockers\r\n(especially from @elastic/kibana-core since there are a few core\r\nspecific changes, though the majority were handled in #149370).\r\n\r\n---------\r\n\r\nCo-authored-by: kibanamachine <[email protected]>","sha":"1b8581540295fde746dae6b4a09d74fb5821bfef"}}]}] BACKPORT--> --------- Co-authored-by: Spencer <[email protected]>
This PR updates the core discovery logic to support loading plugins from packages. This logic is additive, so that the existing plugins in the repo and third-party plugins can continue to be loaded via the existing mechanism, but with #148130 we will be automatically migrating all plugins in the repo to packages, which will use this logic.
The logic is already in-use in that PR, and was developed there, but extracted here for easier review.
The logic is relatively simple, where a list of packages in the repo are attached to the core
Env
and then filtered by core before converting all plugin packages toPluginWrapper
. ThePluginWrapper
still exposes the plugin manifest to the rest of the code, and it is used in many places, so rather than making changes to thePluginWrapper
I'm faking a legacy plugin manifest with the plugin package manifest.@elastic/kibana-core: I'm going to need some help identifying what we need to get test coverage for. This is a pretty simple addition to the core IMO, and if it didn't work then nothing would work, so I'm pretty confident in it, but would still appreciate your feedback.