-
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
[ML] Improve performance of job exists check #77156
[ML] Improve performance of job exists check #77156
Conversation
Pinging @elastic/ml-ui (:ml) |
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.
Code LGTM
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 with optional nit
results[jobId] = body.count > 0; | ||
} catch (e) { | ||
// if a non-wildcarded job id is supplied, the get jobs endpoint will 404 | ||
if (e.body.status !== 404) { |
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: if the caught error isn't returned from ES, but instead is the result of an unexpected runtime error, then there's a possibility that you won't have a body
property defined. Something like this might be more robust:
if (e.body.status !== 404) { | |
if (e.body?.status !== 404) { |
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 endpoint and LGTM
💚 Build SucceededBuild metrics
History
To update your PR or re-run it, just comment with: |
* [ML] Improve performance of job exists check * adding tests * possible undefined error body
* [ML] Improve performance of job exists check * adding tests * possible undefined error body # Conflicts: # x-pack/plugins/ml/server/models/job_service/jobs.ts
* [ML] Improve performance of job exists check (#77156) * [ML] Improve performance of job exists check * adding tests * possible undefined error body # Conflicts: # x-pack/plugins/ml/server/models/job_service/jobs.ts * fixing type error
The endpoint
/api/ml/jobs/jobs_exist
does not need to use a regex to check the job ids as the underlying es endpoint accepts wildcarded ids.Unit or functional tests were updated or added to match the most common scenarios
This was checked for breaking API changes and was labeled appropriately