Make sure to use the max number of failures

This commit is contained in:
Jonathan Leibiusky @xetorthio
2017-09-14 09:57:50 -03:00
parent 7763175e18
commit 3ca50eae2e

View File

@@ -88,9 +88,11 @@ func (s *scheduler) processInstance(ctx context.Context, si *scheduledInstance)
log.Printf("Error retrieving instance %s from storage. Got: %v\n", si.instance.Name, err)
continue
}
failed := false
for _, task := range s.tasks {
err := task.Run(ctx, si.instance)
if err != nil {
failed = true
log.Printf("Error running task %s on instance %s. Got: %v\n", task.Name(), si.instance.Name, err)
// Since one task failed, we just assume something might be wrong with the instance, so we don't try to process the rest of the tasks.
si.fails++
@@ -98,10 +100,12 @@ func (s *scheduler) processInstance(ctx context.Context, si *scheduledInstance)
log.Printf("Instance %s has failed to execute tasks too many times. Giving up.\n", si.instance.Name)
return
}
continue
break
}
}
si.fails = 0
if !failed {
si.fails = 0
}
case <-ctx.Done():
log.Printf("Processing tasks for instance %s has been canceled.\n", si.instance.Name)
return