Uh oh!
There was an error while loading. Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork 214
Fix race condition when restarting continuous jobs#1849
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
Uh oh!
There was an error while loading. Please reload this page.
Changes from all commits
9ccea7440c3448037ded909e1291934ae8078b39a4d060e525506b97f904ea458f1ce9File filter
Filter by extension
Conversations
Uh oh!
There was an error while loading. Please reload this page.
Jump to
Uh oh!
There was an error while loading. Please reload this page.
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -317,6 +317,29 @@ func (r *jobRunner) Cancel(ctx context.Context) error { | ||
| return errGroup.Wait() | ||
| } | ||
| func (r *jobRunner) Restart(ctx context.Context, opts *Options) (output.RunOutput, error) { | ||
| // We don't need to cancel existing runs if the job is continuous and unpaused. | ||
| // the /jobs/run-now API will automatically cancel any existing runs before starting a new one. | ||
| // | ||
| // /jobs/run-now will not cancel existing runs if the job is continuous and paused. | ||
Contributor There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Did you mean "if the job is NOT continuous"? ContributorAuthor There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. No, you can configure jobs to have continuous.pause_status = "PAUSED" in which case it behaves like a non-continuous job. | ||
| // New job runs will be queued instead and will wait for existing runs to finish. | ||
| // In this case, we need to cancel the existing runs before starting a new one. | ||
| continuous := r.job.JobSettings.Continuous | ||
| if continuous != nil && continuous.PauseStatus == jobs.PauseStatusUnpaused { | ||
shreyas-goenka marked this conversation as resolved.
Uh oh!There was an error while loading. Please reload this page. | ||
| return r.Run(ctx, opts) | ||
| } | ||
| s := cmdio.Spinner(ctx) | ||
| s <- "Cancelling all active job runs" | ||
| err := r.Cancel(ctx) | ||
| close(s) | ||
| if err != nil { | ||
| return nil, err | ||
| } | ||
| return r.Run(ctx, opts) | ||
| } | ||
| func (r *jobRunner) ParseArgs(args []string, opts *Options) error { | ||
| return r.posArgsHandler().ParseArgs(args, opts) | ||
| } | ||
Uh oh!
There was an error while loading. Please reload this page.