From 1cb52865bc76445eda2e1eb171992fa934eb83c2 Mon Sep 17 00:00:00 2001 From: Charlie Voiselle Date: Thu, 9 Nov 2017 10:10:11 -0500 Subject: [PATCH] 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. --- api/tasks.go | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/api/tasks.go b/api/tasks.go index c956aac30..613aff5b3 100644 --- a/api/tasks.go +++ b/api/tasks.go @@ -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)