Merge pull request #69 from sgotti/runservice_fix_executor_delete

runservice: fix/improve executor delete logic
This commit is contained in:
Simone Gotti 2019-07-29 14:42:41 +02:00 committed by GitHub
commit fe90eecf62
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 8 additions and 16 deletions

View File

@ -554,21 +554,6 @@ func (h *ActionHandler) ApproveRunTask(ctx context.Context, req *RunTaskApproveR
} }
func (h *ActionHandler) DeleteExecutor(ctx context.Context, executorID string) error { 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 { if err := store.DeleteExecutor(ctx, h.e, executorID); err != nil {
return err return err
} }

View File

@ -836,7 +836,15 @@ func (s *Runservice) executorTaskCleaner(ctx context.Context, et *types.Executor
} }
if executor == nil { if executor == nil {
log.Warnf("executor with id %q doesn't exist. marking executor task %q as failed", et.Status.ExecutorID, et.ID) 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.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 { if _, err := store.AtomicPutExecutorTask(ctx, s.e, et); err != nil {
return err return err
} }
@ -1301,7 +1309,6 @@ func (s *Runservice) finishedRunsArchiver(ctx context.Context) error {
// finishedRunArchiver archives a run if it's finished and all the fetching // finishedRunArchiver archives a run if it's finished and all the fetching
// phases (logs and archives) are marked as finished // phases (logs and archives) are marked as finished
func (s *Runservice) finishedRunArchiver(ctx context.Context, r *types.Run) error { func (s *Runservice) finishedRunArchiver(ctx context.Context, r *types.Run) error {
//log.Debugf("r: %s", util.Dump(r))
if !r.Phase.IsFinished() { if !r.Phase.IsFinished() {
return nil return nil
} }