-
Notifications
You must be signed in to change notification settings - Fork 8.2k
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
[NP migration] Shim ILM #56068
[NP migration] Shim ILM #56068
Conversation
Pinging @elastic/es-ui (Team:Elasticsearch UI) |
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.
Good first step! Just a couple suggestions / tips.
export interface CoreSetup { | ||
server: Legacy.Server; | ||
} |
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.
You may want to use the LegacySetup
pattern that was recently added to the Migration Guide.
The gist for this is, add a 3rd argument to your plugin lifecycle method that represents all the legacy dependencies, and use the real CoreSetup interface as the first argument. This makes it easier to identify which parts still need to be migrated away from Legacy APIs and which parts are using the real CoreSetup APIs.
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.
Thanks, Josh. I attempted to implement this pattern in f35f1b5, but I'm not entirely sure if this is correct.
import { PLUGIN_ID } from '../../../common/constants'; | ||
import { wrapCustomError } from '../error_wrappers'; | ||
|
||
export const licensePreRoutingFactory = once(server => { |
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.
Just an FYI, I just opened a PR for adding examples of how to migrate these pre-route handlers: #56080. Not relevant for this PR, but should be helpful for completing the server-side.
@joshdover Would you mind reviewing my latest commit, which shims the public directory? |
c21fa42
to
9eafd5e
Compare
// NOTE: We depend upon Angular's $http service because it's decorated with interceptors, | ||
// e.g. to check license status per request. |
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 core.http.*
APIs have the same interceptors installed as well.
element: HTMLElement; | ||
} | ||
|
||
export const boot = (appDependencies: AppDependencies) => { |
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.
By convention this should be named renderApp
.
const esSection = management.getSection('elasticsearch'); | ||
esSection.register('index_lifecycle_policies', { | ||
visible: true, | ||
display: PLUGIN.TITLE, | ||
order: 2, | ||
url: `#${BASE_PATH}policies`, | ||
}); |
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.
FYI once you're app is de-coupled from Angular, you can leverage the new Management plugin in the NP. Can do this in the next PR though.
application: { | ||
...npSetup.core.application, | ||
async register(app: App) { | ||
const unmountApp = await app.mount({ ...npStart } as any, { | ||
element, | ||
appBasePath: '', | ||
onAppLeave: () => undefined, | ||
}); | ||
manageAngularLifecycle($scope, $route, unmountApp as any); | ||
}, | ||
}, |
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.
In the case of a management section app, you'll be using the management plugin's API instead of the Application service since this is not a top-level app. You can see the management API here: https://github.com/elastic/kibana/blob/master/src/plugins/management/public/types.ts#L25
kbnUrl.redirect(path); | ||
}); | ||
}, | ||
fatalError, |
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.
There is an NP API on CoreSetup.fatalErrors
- Move UI metric constants into public directory.
- Refactor DI pattern of Index Mangement extensions to require various NP service dependencies.
9eafd5e
to
af15a71
Compare
@@ -211,7 +216,20 @@ export class IndexActionsContextMenu extends Component { | |||
}, | |||
}); | |||
getActionExtensions().forEach(actionExtension => { | |||
const actionExtensionDefinition = actionExtension(indices, reloadIndices); | |||
const actionExtensionDefinition = actionExtension({ |
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.
@sebelga Just a head's up that a few files are changing in Index Management, which we'll need to reconcile.
If I merge this PR in before you finish migrating Index Management then you'll just need to reconcile the conflicts by accepting these changes but passing in the NP http service in lieu of getNewPlatformCompatibleHttpClient
.
If you merge in the Index Management migration before I merge this PR then I'll be able to reconcile the conflicts myself, but I don't think that's the best way to proceed. It would create less work for you to wait for this PR to get merged first, because then you won't need to preserve the dependency upon Angular's $http
service.
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.
OK no problem, thanks for the heads up @cjcenizal !
- Update Index Management to provide a NP-compatible adapater around Angular's $http service. - Remove unused sendPut method from API service. - Update http error handling to consume NP http service errors.
af15a71
to
0b9e0ab
Compare
|
||
// We will be able to remove this after the NP migration is complete and we can just inject the | ||
// NP fatalErrors service.. | ||
const getNewPlatformCompatibleFatalErrorService = () => ({ |
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.
@sebelga Here's another example of a service adapter that will become unnecessary as part of your migration.
@joshdover Thanks for the review! I've made the changes you suggested. Could you please re-review? |
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.
Shims LGTM
…dency upon Angular's $http.
9acd7ef
to
225bf51
Compare
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.
@cjcenizal great work on this! 🎉
Code
Left a few comments and a question about when we should introduce IRouter
. No other blockers.
UI/UX
- UI looks good, didn't see any visual regressions!
- I was not able to get step 5 of the
Testing the Index Management extensions
section in the PR description, everything else seemed to work!
registerLicenseChecker(server); | ||
|
||
// Register routes. | ||
registerIndexRoutes(server); |
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.
As part of this shimming, is it worth migrating the http routes to use the new platform IRouter
? It should be available on CoreSetup
which I see we are passing in from x-pack/legacy/plugins/index_lifecycle_management/index.ts
. It does affect all of the routes so happy if this done later.
I think it is most useful that when we migrate the routes we don't pass the legacy server
object in directly but rather create a RouteDependencies
object that contains a __LEGACY
entry. That way all of the legacy interfaces are clearly marked here and downstream.
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.
+1 Agreed. Let's discuss later at the sync those conventions as I am also afraid of other places we might do things differently.
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'll migrate to the NP router in a subsequent PR. I agree that it would be great if we could align on a convention.
// The extend_index_management module that we support an injected httpClient here. | ||
|
||
export async function loadNodes(httpClient) { | ||
const response = await sendGet(`nodes/list`, httpClient); |
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: unnecessary creation of response
constant. Can just return send...
. Same for other instances below. In some cases the await
can also be omitted if just a one-liner.
import { i18n } from '@kbn/i18n'; | ||
export function checkLicense(xpackLicenseInfo) { | ||
|
||
export function checkLicense(xpackLicenseInfo: any): any { |
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 think there are typings available for this here: x-pack/legacy/plugins/xpack_main/server/lib/xpack_info.ts
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.
Thanks, I'll use them in the subsequent PR when I make more significant changes to the server.
Jenkins test this |
@elasticmachine merge upstream |
628e162
to
dd320e4
Compare
@elasticmachine merge upstream |
1 similar comment
@elasticmachine merge upstream |
87e8137
to
2801485
Compare
@elasticmachine merge upstream |
Jenkins test this |
@elasticmachine merge upstream |
💚 Build SucceededHistory
To update your PR or re-run it, just comment with: |
- Move UI metric constants into public directory. - Convert server-side code to TS, largely with use of any. - Remove unused sendPut method from API service. - Update http error handling to consume NP http service errors. - Refactor DI pattern of Index Mangement extensions to require various NP service dependencies. - Inject NP http service into Index Management extensions. Remove dependency upon Angular's $http.
- Move UI metric constants into public directory. - Convert server-side code to TS, largely with use of any. - Remove unused sendPut method from API service. - Update http error handling to consume NP http service errors. - Refactor DI pattern of Index Mangement extensions to require various NP service dependencies. - Inject NP http service into Index Management extensions. Remove dependency upon Angular's $http.
Test plan
xpack.ilm.ui.enabled: false
Testing the Index Management extensions
Verification that dependencies still function
Toasts
Fatal error
Fetching index templates
Fetching nodes
Fetching node details
Index Management extension