-
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
[Task manager] Adds ensureScheduled api to allow safer rescheduling of existing tasks #50232
[Task manager] Adds ensureScheduled api to allow safer rescheduling of existing tasks #50232
Conversation
Pinging @elastic/kibana-stack-services (Team:Stack Services) |
💔 Build Failed |
…is included in lens, maps and telemetry
💔 Build Failed |
💔 Build Failed |
@elasticmachine merge upstream |
💔 Build Failed |
💔 Build Failed |
💚 Build Succeeded |
💚 Build Succeeded |
I don't see any issues calling it The interface |
Yeah, I was really unsure with that naming :) |
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. Thanks for tackling this.
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, but made a comment about changing a comment :-)
* The id of the Elastic document that stores this instance's data. This can | ||
* be passed by the caller when scheduling the task. | ||
*/ | ||
id: 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.
wow, TIL. You can subclass an interface, changing a super-interface's property from optional to not optional. Neat-O!
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.
That's changed now, as I'm using a new Utility type marking id
as Required ;)
But the name is now TaskInstanceWithId
.
public async ensureScheduling( | ||
taskInstance: ExistingTaskInstance, | ||
options?: any | ||
): Promise<ExistingTaskInstance> { |
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.
So I guess sometimes this will return a ConcreteTaskInstance
(if not already scheduled), but otherwise the taskInstance
sent in. Seems like it would be "nice" if it did always return a ConcreteTaskInstance
, but guessing you will have to do another read to get that, and hardly seems worth it, since the caller may not need it. Seems like this should be fine as a first attempt, maybe we'd need to re-look at a way to get the ConcreteTaskInstance back later, if we find we need it for some reason.
In any case, the JSDoc comment above this should be changed to say it's returning an ExistingTaskInstance
instead of ConcreteTaskInstance
.
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, I did think about that, though, the type it returns will always be TaskInstanceWithId
, never an explicit ConcreteTaskInstance
, as TaskInstanceWithId
is essentially a subtype of ConcreteTaskInstance
, but you're right that otherwise we'd have to make an additional read and it didn't seem worth it.
Feels reasonable to leave it such due to the ensure nature, no?
I'll change the JSDoc, thanks for catching 👍
Same feels on the new names as everyone, I guess. |
Weird, to me
Already changed :) |
@@ -10,6 +10,8 @@ import Joi from 'joi'; | |||
* Type definitions and validations for tasks. | |||
*/ | |||
|
|||
type Require<T extends object, P extends keyof T = keyof T> = Omit<T, P> & Required<Pick<T, P>>; |
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 this new Require
type could use a short comment - not immediately clear what it's doing :-)
@@ -82,7 +82,7 @@ function scheduleTasks(server: Server) { | |||
// function block. | |||
(async () => { | |||
try { | |||
await taskManager.schedule({ | |||
await taskManager.ensureScheduled({ |
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
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.
Lens part LGTM
@elasticmachine merge upstream |
💚 Build Succeeded |
…of existing tasks (elastic#50232) Adds an ensureScheduling api to Task Manager which allow safer rescheduling of existing tasks by handling the case where a Task with a known ID is scheduled and clashes with an existing schedule of that same task.
💚 Build Succeeded |
…ger-ace-theme * 'master' of github.com:elastic/kibana: (54 commits) [ML] Fixes word wrap in Overview page sidebar on IE (elastic#50668) Upgrade to TypeScript 3.7.2 (elastic#47188) fix: hide 'edit' button for mobile for dashboards (elastic#50639) fixes conditional links tests (elastic#50642) [SIEM] Fix IE11 timeline drag and drop issue (elastic#50528) [SIEM] Add SavedQuery in Timeline (elastic#49813) chore(NA): remove code plugin from codeowners (elastic#50451) [DOCS] Adds documentation on telemetry settings (elastic#50739) [Logs UI] Add IE11-specific CSS fixes for anomalies table (elastic#49980) [DOCS][SIEM]: Change Kibana advanced settings to match UI (elastic#50679) Change URLs for support menu (elastic#50700) [Reporting] Remove any types and references to Hapi (elastic#49250) [DOCS] Adds note about backups to Upgrade doc (elastic#50525) [Logs UI] Improve infra plugin compatibility with TS 3.7 (elastic#50491) [Task manager] Adds ensureScheduling api to allow safer rescheduling of existing tasks (elastic#50232) [DOCS] Adds link to content security policy doc (elastic#50698) Remove duplicate but in error message (elastic#50530) [ML] DF Analytics: Ensure creation flyout can be opened when no jobs exist (elastic#50417) Add filebeat notice (elastic#49065) [Monitoring] De-duplicate pipeline ids based on the ephemeral_id changing (elastic#49978) ... # Conflicts: # x-pack/legacy/plugins/grokdebugger/public/components/grok_debugger/brace_imports.ts
…of existing tasks (elastic#50232) Adds an ensureScheduling api to Task Manager which allow safer rescheduling of existing tasks by handling the case where a Task with a known ID is scheduled and clashes with an existing schedule of that same task.
…of existing tasks (elastic#50232) Adds an ensureScheduling api to Task Manager which allow safer rescheduling of existing tasks by handling the case where a Task with a known ID is scheduled and clashes with an existing schedule of that same task.
Summary
Adds an
ensureScheduled
api to Task Manager which allow safer rescheduling of existing tasks by handling the case where a Task with a known ID is scheduled and clashes with an existing schedule of that same task.fixes #41827
fixed #32050
Checklist
Use
strikethroughsto remove checklist items you don't feel are applicable to this PR.This was checked for cross-browser compatibility, including a check against IE11Any text added follows EUI's writing guidelines, uses sentence case text and includes i18n supportThis was checked for keyboard-only and screenreader accessibilityFor maintainers