Skip to content

Commit

Permalink
start new jobs when forcing job start
Browse files Browse the repository at this point in the history
Signed-off-by: Stephen Gutekanst <[email protected]>
  • Loading branch information
emidoots committed Oct 18, 2023
1 parent e0e58e2 commit ef4bca7
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions internal/wrench/scheduler.go
Original file line number Diff line number Diff line change
Expand Up @@ -223,15 +223,16 @@ func (b *Bot) scheduleJob(ctx context.Context, schedule ScheduledJob, runners []
return "", errors.Wrap(err, "failed to query last job")
}

start := lastJob == nil || (lastJob.State != api.JobStateReady &&
startable := lastJob == nil || (lastJob.State != api.JobStateReady &&
lastJob.State != api.JobStateStarting &&
lastJob.State != api.JobStateRunning)
if start && schedule.Every == 0 {
start = false // Job can be started, but is not scheduled to start automatically.
shouldStart := startable
if startable && schedule.Every == 0 {
shouldStart = false // Job can be started, but is not scheduled to start automatically.
}

if !start && force {
if lastJob != nil {
if !shouldStart && force {
if startable {
lastJob.ScheduledStart = time.Time{}
if err := b.store.UpsertRunnerJob(ctx, *lastJob); err != nil {
return "", errors.Wrap(err, "failed to update job")
Expand All @@ -247,7 +248,7 @@ func (b *Bot) scheduleJob(ctx context.Context, schedule ScheduledJob, runners []
return jobID, nil
}
}
if !start {
if !shouldStart {
return "", nil
}

Expand Down

0 comments on commit ef4bca7

Please sign in to comment.