-
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
[ML] New Platform server shim: update annotation routes to use new platform router #57067
[ML] New Platform server shim: update annotation routes to use new platform router #57067
Conversation
Pinging @elastic/ml-ui (:ml) |
💔 Build Failed
Test FailuresKibana Pipeline / x-pack-intake-agent / X-Pack Jest Tests.x-pack/legacy/plugins/ml/server/models/annotation_service.annotation_service deleteAnnotation() should delete annotationStandard Out
Stack Trace
Kibana Pipeline / x-pack-intake-agent / X-Pack Jest Tests.x-pack/legacy/plugins/ml/server/models/annotation_service.annotation_service getAnnotation() should get annotations for specific jobStandard Out
Stack Trace
Kibana Pipeline / x-pack-intake-agent / X-Pack Jest Tests.x-pack/legacy/plugins/ml/server/models/annotation_service.annotation_service getAnnotation() should throw and catch an errorStandard Out
Stack Trace
and 3 more failures, only showing the first 3. To update your PR or re-run it, just comment with: |
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.
Looks good overall, just added some questions/suggestions.
@@ -67,7 +68,8 @@ export type callWithRequestType = ( | |||
params: annotationProviderParams | |||
) => Promise<any>; | |||
|
|||
export function annotationProvider(callWithRequest: callWithRequestType) { | |||
export function annotationProvider(context: RequestHandlerContext) { | |||
const callAsCurrentUser = context.ml!.mlClient.callAsCurrentUser; |
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.
Can we work around this in another way? The styleguide says to avoid non-null assertions https://github.com/elastic/kibana/blob/master/STYLEGUIDE.md#avoid-non-null-assertions
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 agree, this has been bothering me too in the recent NP work.
Does ml
need to be optional in our RequestHandlerContext
interface? especially as we're asserting that it isn't optional in every route.
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.
Adding ml
to the RequestHandlerContext
interface was initially made optional to prevent issues with other plugins using RequestHandlerContext
. This was the suggested definition from kibana-platform.
Had a chat with Josh about this and looks like they'll be improving this by adding a generic type arg to core.http.createRouter
so you can specify your own type for RequestHandlerContext
. The PR should be up soon. Then we'll be able to get rid of the non-null assertions. 🙌
So we're stuck with this for now but once that PR is in we can add the change in the next routes PR 👌
{ | ||
path: '/api/ml/annotations', | ||
validate: { | ||
body: schema.object({ |
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 do you think of moving all schema definitions to new_platform/annotations_schema.ts
for consistency even if they are not as complex as the indexAnnotationSchema
one?
{ | ||
path: '/api/ml/annotations/delete/{annotationId}', | ||
validate: { | ||
params: schema.object({ annotationId: schema.string() }), |
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 do you think of moving all schema definitions to new_platform/annotations_schema.ts
for consistency even if they are not as complex as the indexAnnotationSchema
one?
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.
f059e07
to
a3b489d
Compare
} | ||
|
||
const { indexAnnotation } = annotationServiceProvider(context); | ||
const username = _.get(request, 'auth.credentials.username', ANNOTATION_USER_UNKNOWN); |
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 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.
Looks like this is no longer available in the NP request object. It has to be accessed via the NP security plugin api - added in a4ad5a5039fd1c809bbb121a9bc327a63ce8a53b
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.
Tested latest edits and LGTM
Thanks, everyone, for taking a look 😄 This is ready for a final check when you get a chance! cc @jgowdyelastic, @walterra |
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.
LGTM
a4ad5a5
to
8a9892a
Compare
💚 Build SucceededHistory
To update your PR or re-run it, just comment with: |
…atform router (elastic#57067) * update annotation routes to use NP router * create ts file for feature check * update schema to allow null value for earliest/latestMs * update annotations model test * use NP security plugin to access user info
* master: (27 commits) Include actions new platform plugin for codeowners (elastic#57252) [APM][docs] 7.6 documentation updates (elastic#57124) Expressions refactor (elastic#54342) [ML] New Platform server shim: update annotation routes to use new platform router (elastic#57067) Remove injected ui app vars from Canvas (elastic#56190) update max_anomaly_score route schema to handle possible undefined values (elastic#57339) [Add panel flyout] Moving create new to the top of SavedObjectFinder (elastic#56428) Add mock of a legacy ui api to re-enable Canvas storybook (elastic#56673) [monitoring] Removes noisy event received log (elastic#57275) Remove use of copied MANAGEMENT_BREADCRUMBS and use `setBreadcrumbs` from management section's mount (elastic#57324) Advanced Settings management app to kibana platform plugin (elastic#56931) [ML] New Platform server shim: update recognize modules routes to use new platform router (elastic#57206) [ML] Fix overall stats for saved search on the Data Visualizer page (elastic#57312) [ML] [NP] Removing ui imports (elastic#56358) [SIEM] Fixes failing Cypress tests (elastic#57202) Create observability CODEOWNERS reference (elastic#57109) fix results service schema (elastic#57217) don't register a wrapper if browser side function exists. (elastic#57196) Ui Actions explorer example (elastic#57006) Fix update alert API to still work when AAD is out of sync (elastic#57039) ...
Summary
Updates all annotation routes to use new platform router.
Checklist
Delete any items that are not applicable to this PR.