Canonicalize task and remove merge with MinResources

The current code would merge the job with the output of MinResources causing the nil to be replaced with MemoryMB=helper.IntToPtr(10).  When later `Canonicalize`d, the 10 would cause the default of 300 not to be applied. Running `Canonicalize` on the task itself guarantees that CPU, MemoryMB, and IOPS is set, so we can remove the Merge withMinResources.
This commit is contained in:
Charlie Voiselle 2017-11-09 10:10:11 -05:00
parent ff5d1a90a4
commit eda45a0cee

View file

@ -186,7 +186,7 @@ func (s *Service) Canonicalize(t *Task, tg *TaskGroup, job *Job) {
s.CheckRestart.Canonicalize()
// Canonicallize CheckRestart on Checks and merge Service.CheckRestart
// Canonicalize CheckRestart on Checks and merge Service.CheckRestart
// into each check.
for _, c := range s.Checks {
c.CheckRestart.Canonicalize()
@ -374,9 +374,7 @@ type Task struct {
func (t *Task) Canonicalize(tg *TaskGroup, job *Job) {
min := MinResources()
min.Merge(t.Resources)
min.Canonicalize()
t.Resources = min
t.Resources.Canonicalize()
if t.KillTimeout == nil {
t.KillTimeout = helper.TimeToPtr(5 * time.Second)