Skip to content

Commit

Permalink
runservice: fix/improve executor delete logic
Browse files Browse the repository at this point in the history
* Don't fail tasks inside the delete executor action, just delete the executor
from etcd

* The scheduler, when detecting a task without a related executor will mark the
task as failed and correctly set end time of the task and its steps.
  • Loading branch information
sgotti committed Jul 29, 2019
1 parent 504cd3d commit b81ad4c
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 16 deletions.
15 changes: 0 additions & 15 deletions internal/services/runservice/action/action.go
Original file line number Diff line number Diff line change
Expand Up @@ -554,21 +554,6 @@ func (h *ActionHandler) ApproveRunTask(ctx context.Context, req *RunTaskApproveR
}

func (h *ActionHandler) DeleteExecutor(ctx context.Context, executorID string) error {
// mark all executor tasks as failed
ets, err := store.GetExecutorTasks(ctx, h.e, executorID)
if err != nil {
return err
}

for _, et := range ets {
et.Status.Phase = types.ExecutorTaskPhaseFailed
et.FailError = "executor deleted"
if _, err := store.AtomicPutExecutorTask(ctx, h.e, et); err != nil {
return err
}
}

// delete the executor
if err := store.DeleteExecutor(ctx, h.e, executorID); err != nil {
return err
}
Expand Down
9 changes: 8 additions & 1 deletion internal/services/runservice/scheduler.go
Original file line number Diff line number Diff line change
Expand Up @@ -836,7 +836,15 @@ func (s *Runservice) executorTaskCleaner(ctx context.Context, et *types.Executor
}
if executor == nil {
log.Warnf("executor with id %q doesn't exist. marking executor task %q as failed", et.Status.ExecutorID, et.ID)
et.FailError = "executor deleted"
et.Status.Phase = types.ExecutorTaskPhaseFailed
et.Status.EndTime = util.TimePtr(time.Now())
for _, s := range et.Status.Steps {
if s.Phase == types.ExecutorTaskPhaseRunning {
s.Phase = types.ExecutorTaskPhaseFailed
s.EndTime = util.TimePtr(time.Now())
}
}
if _, err := store.AtomicPutExecutorTask(ctx, s.e, et); err != nil {
return err
}
Expand Down Expand Up @@ -1301,7 +1309,6 @@ func (s *Runservice) finishedRunsArchiver(ctx context.Context) error {
// finishedRunArchiver archives a run if it's finished and all the fetching
// phases (logs and archives) are marked as finished
func (s *Runservice) finishedRunArchiver(ctx context.Context, r *types.Run) error {
//log.Debugf("r: %s", util.Dump(r))
if !r.Phase.IsFinished() {
return nil
}
Expand Down

0 comments on commit b81ad4c

Please sign in to comment.