-
Notifications
You must be signed in to change notification settings - Fork 427
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
feat(orchestrator): pause/unpause/delete sync #2289
Conversation
@@ -15,7 +15,8 @@ interface ScheduleStateTransition { | |||
export const validScheduleStateTransitions = [ | |||
{ from: 'STARTED', to: 'PAUSED' }, | |||
{ from: 'STARTED', to: 'DELETED' }, | |||
{ from: 'PAUSED', to: 'STARTED' } | |||
{ from: 'PAUSED', to: 'STARTED' }, | |||
{ from: 'PAUSED', to: 'DELETED' } |
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.
Missed state transition. Deleting a paused schedule should be allowed
1529f72
to
aba00f1
Compare
@@ -344,7 +370,6 @@ export class OrchestratorClient { | |||
} | |||
} | |||
|
|||
//TODO: rename to cancelTask? |
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 don't think we are gonna need a cancelSync.
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 you explain what you mean by this exactly?
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 cancel
function is cancelling a task (aka: a sync execution). Yesterday I though we might need to have a cancelSchedule
so I added a TODO to rename the existing function to cancelTask
. But it happens that we don't cancel schedule (which are only paused/unpaused or deleted), only tasks/jobs. So keeping the name cancel
for the function is ok for now
aba00f1
to
af26ce7
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.
Question inline
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.
🎷
if (schedule.isErr()) { | ||
return res.status(500).json({ error: { code: 'recurring_failed', message: schedule.error.message } }); | ||
} | ||
return res.status(201).json({ scheduleId: schedule.value.id }); |
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.
nitpick: 200 might be more accurate
01ad8ca
to
be91544
Compare
Built on top of #2289 (please review it first) Implementing `runSyncCommand` in orchestrator. I am not sure I understand the split of responsibility between `sync.client` and `orchestrator.service`. `sync.client runSyncCommand` is called by `orchestration.service runSyncCommand` but it is also called directly in a few places: for example [here](https://github.com/NangoHQ/nango/blob/dee08827d78616c013c4f3e27ddad53f46a7a298/packages/jobs/lib/crons/autoIdleDemo.ts#L81) and [here](https://github.com/NangoHQ/nango/blob/dee08827d78616c013c4f3e27ddad53f46a7a298/packages/server/lib/controllers/sync.controller.ts#L746). Same thing happens with the creation of sync schedules where there are 3 mains path to `startContinuous`, `deploys` goes through the `orchestrator.service` but `connectionCreatedHook` calls the `sync.client` directly 😢 This make it very hard to have clean transition code. I have created a temporary function to take care of the feature flag branching. Code will be refactored once temporal is removed. For now no schedule is being created in the orchestrator so all commands would fail if the flag is turned on. Next PR will add the creation of schedules. ## Checklist before requesting a review (skip if just adding/editing APIs & templates) - [ ] I added tests, otherwise the reason is: - [ ] I added observability, otherwise the reason is: - [ ] I added analytics, otherwise the reason is:
Adding way to pause/unpause/delete a schedule in the orchestrator
Also allowing to create a schedule in paused state. This is going to be required to support sync auto_start
Issue ticket number and link
Checklist before requesting a review (skip if just adding/editing APIs & templates)