Skip to content
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

fix(task): fix an issue where tasks fail to resume on claim #14356

Merged
merged 1 commit into from
Jul 16, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 8 additions & 6 deletions task/backend/scheduler.go
Original file line number Diff line number Diff line change
Expand Up @@ -307,8 +307,6 @@ func (s *TickScheduler) ClaimTask(authCtx context.Context, task *platform.Task)
return err
}

s.taskSchedulers[task.ID] = ts

// pickup any runs that are still "running from a previous failure"
runs, err := s.taskControlService.CurrentlyRunning(authCtx, task.ID)
if err != nil {
Expand All @@ -320,6 +318,8 @@ func (s *TickScheduler) ClaimTask(authCtx context.Context, task *platform.Task)
}
}

s.taskSchedulers[task.ID] = ts

next, hasQueue := ts.NextDue()
if now := atomic.LoadInt64(&s.now); now >= next || hasQueue {
ts.Work()
Expand Down Expand Up @@ -509,8 +509,9 @@ func (ts *taskScheduler) Work() {
}

func (ts *taskScheduler) WorkCurrentlyRunning(runs []*platform.Run) error {
foundWorker := false

for _, cr := range runs {
foundWorker := false
for _, r := range ts.runners {
t, err := time.Parse(time.RFC3339, cr.ScheduledFor)
if err != nil {
Expand All @@ -523,9 +524,10 @@ func (ts *taskScheduler) WorkCurrentlyRunning(runs []*platform.Run) error {
}
}

if !foundWorker {
return errors.New("worker not found to resume work")
}
}

if !foundWorker {
return errors.New("worker not found to resume work")
}

return nil
Expand Down