[ML] NP: migrate server#58680
Conversation
|
Pinging @elastic/ml-ui (:ml) |
There was a problem hiding this comment.
I think it's ok to call getLicenseCheckResults again in here rather than caching the license object locally.
getLicenseCheckResults just returns the already created license results object and has no overhead.
job_service.ts is doing this without a cache also in this file on line 80.
There was a problem hiding this comment.
Updated in 609be5c4c218d1feed4b249158c438ce7c30f99d
There was a problem hiding this comment.
commented code can be removed
There was a problem hiding this comment.
609be5c4c218d1feed4b249158c438ce7c30f99d
There was a problem hiding this comment.
commented code can be removed
There was a problem hiding this comment.
609be5c4c218d1feed4b249158c438ce7c30f99d
x-pack/plugins/ml/server/plugin.ts
Outdated
There was a problem hiding this comment.
all 'ml' strings in this file could be PLUGIN_ID from types.ts
There was a problem hiding this comment.
Good call - added in 609be5c4c218d1feed4b249158c438ce7c30f99d
x-pack/plugins/ml/server/types.ts
Outdated
There was a problem hiding this comment.
it'd be good to move this to common as we often need this string client side. it could go in app.ts.
(also API_BASE_PATH in there can go as it's a leftover from transforms being in ML)
There was a problem hiding this comment.
Updated in 609be5c4c218d1feed4b249158c438ce7c30f99d
x-pack/plugins/ml/server/plugin.ts
Outdated
There was a problem hiding this comment.
this should have a type so we can use it in each route.
There was a problem hiding this comment.
Added in 609be5c4c218d1feed4b249158c438ce7c30f99d
x-pack/plugins/ml/server/plugin.ts
Outdated
There was a problem hiding this comment.
i wonder if it's worth merging these into a single object?
An alternative approach could be to pass the routeInit as a single first argument to each route, so they are all the same, and for the routes that require additional information, pass that as a second argument.
The routes themselves could then manage the type of that second "additional dependancies" parameter.
Something like:
systemRoutes(routeInit, {
spacesPlugin: plugins.spaces,
cloud: plugins.cloud,
});
There was a problem hiding this comment.
Good idea - used the second idea of having an 'additional dependencies' second parameter where applicable. 609be5c4c218d1feed4b249158c438ce7c30f99d
x-pack/plugins/ml/server/plugin.ts
Outdated
There was a problem hiding this comment.
This should include enterprise too, in line with the list of VALID_FULL_LICENSE_MODES in server/lib/check_license/check_license.ts. We should probably define that list of full license modes in e.g. common/constants/license.ts.
There was a problem hiding this comment.
Updated and moved to constants/license.ts in 609be5c4c218d1feed4b249158c438ce7c30f99d
There was a problem hiding this comment.
See other comment regarding moving this into a common constants file. Could be done in the follow-up to fix the licensing checks.
There was a problem hiding this comment.
609be5c4c218d1feed4b249158c438ce7c30f99d
There was a problem hiding this comment.
Are all these commented out lines for the RouteInitialization needed in all the routes files?
There was a problem hiding this comment.
RouteInitialization could be reused for my requested change.
#58680 (comment)
There was a problem hiding this comment.
Done in 609be5c4c218d1feed4b249158c438ce7c30f99d
|
Gave this a good test, and all works well, apart from the ML item with the Jobs List doesn't appear in the Management app. Is this related to the licensing work that needs to be done? |
x-pack/legacy/plugins/ml/index.ts
Outdated
There was a problem hiding this comment.
managementSections: ['plugins/ml/application/management'], on line 24 isn't registering our management section anymore.
Is there a NP equivalent?
(github wouldn't let me add this to line 24)
There was a problem hiding this comment.
There is, but I think it should work. Maybe this this an issue with the fact that there is now both a x-pack/legacy/plugins/ml and x-pack/plugins/ml folders? But the NP ml plugin has no public part, so I'm not sure to understand. @elastic/kibana-app-arch would you mind to take a look?
There was a problem hiding this comment.
@jgowdyelastic - looks like the issue is that in applicatoins/management the code to register the app in management is wrapped in an if block that relies on legacy xpackInfo.
The solution is to use the frontend licensing service - npSetup.plugins.licensing where npSetup comes from import { npSetup } from 'ui/new_platform'
Then we can can pull the relevant license info from
licensing.license$.subscribe(async license => {
if (license.type && VALID_FULL_LICENSE_MODES.includes(license.type)) {
... <register management app>
Probably this same approached can be used in the work you'll be doing for check_license.tsx @jgowdyelastic 🤔
cc @peteharverson for context
x-pack/plugins/ml/server/types.ts
Outdated
There was a problem hiding this comment.
this should be SecurityPluginSetup
There was a problem hiding this comment.
609be5c4c218d1feed4b249158c438ce7c30f99d
x-pack/plugins/ml/server/types.ts
Outdated
There was a problem hiding this comment.
this should be CloudSetup
There was a problem hiding this comment.
609be5c4c218d1feed4b249158c438ce7c30f99d
x-pack/legacy/plugins/ml/kibana.json
Outdated
There was a problem hiding this comment.
This file doesn't do anything in legacy. I would remove it completely.
There was a problem hiding this comment.
Removed in 609be5c4c218d1feed4b249158c438ce7c30f99d
|
Registering the management section can be addressed in a follow-up PR as we have to do follow up work for licensing issues as well. This has been updated for all comments and is ready for final look cc @jgowdyelastic, @peteharverson, @joshdover |
jgowdyelastic
left a comment
There was a problem hiding this comment.
Tested and LGTM!
This PR is a cut (over) above the rest!
It certainly makes the cut (over)!
Sorry, yeah I know, I could cut (over) it out.
peteharverson
left a comment
There was a problem hiding this comment.
Latest edits LGTM!
609be5c to
2560317
Compare
|
retest |
joshdover
left a comment
There was a problem hiding this comment.
No major issues spotted 👍
x-pack/plugins/ml/server/plugin.ts
Outdated
There was a problem hiding this comment.
Not a huge concern, but you should unsubscribe from this observable in the stop phase.
There was a problem hiding this comment.
Oh good catch - added to checklist 👍
x-pack/plugins/ml/server/plugin.ts
Outdated
There was a problem hiding this comment.
How did this work before / what is the approach to solving this in the follow up?
2560317 to
53c2b6f
Compare
53c2b6f to
3a872d5
Compare
💚 Build SucceededHistory
To update your PR or re-run it, just comment with: |
* remove obsolete legacy server deps * licensePreRoutingFactory uses licensing plugin rather than legacy xpack * move schemas to dir in routes * use NP license check method for license check * store license data in plugin for passing to check * create server plugin files in NP plugin dir * remove dependency on legacy xpack plugin * add sample data links first step * move all server dirs from legacy to np dir * fix requiredPlugin spaces name and update import routes * delete unnecessary files and add sample data links * update license and privilege check tests * add routeInit types
* remove obsolete legacy server deps * licensePreRoutingFactory uses licensing plugin rather than legacy xpack * move schemas to dir in routes * use NP license check method for license check * store license data in plugin for passing to check * create server plugin files in NP plugin dir * remove dependency on legacy xpack plugin * add sample data links first step * move all server dirs from legacy to np dir * fix requiredPlugin spaces name and update import routes * delete unnecessary files and add sample data links * update license and privilege check tests * add routeInit types
Summary
Migrate legacy server to NP.
Create server plugin/index for
mlinx-pack/pluginsMove all
legacy/serverfiles toplugins/mlUpdate all shared type/constants/etc imports in NP server to import from
legacy/(once client is fully moved over those import paths can be updated)NOTES
x-pack/legacy/plugins/ml/public/application/license/check_license.tsxgetFeatureshas been hardcoded to return full permissions for now. This will be handled in a follow-up.In the NP plugin license check,
isAvailableis set toisEnabledfor now as the NP license check returns false forisAvailablewith a basic license - ML should be available on basic with very reduced functionality. This will also be sorted in the follow up.Checklist
Delete any items that are not applicable to this PR.