From 20ea6b25dcc3e1629bc7b05e6b09e0e53623db17 Mon Sep 17 00:00:00 2001 From: Charlie Voiselle Date: Thu, 9 Nov 2017 10:57:57 -0500 Subject: [PATCH] Adopted pattern from LogConfig to handle panic when no resource stanza at all In testing realized that Resources night not be present at all. Testing this case caused panic. Added in a means to collect clean defaults in that case. --- api/tasks.go | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/api/tasks.go b/api/tasks.go index 613aff5b3..8dff2b582 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() - // Canonicalize CheckRestart on Checks and merge Service.CheckRestart + // Canonicallize CheckRestart on Checks and merge Service.CheckRestart // into each check. for _, c := range s.Checks { c.CheckRestart.Canonicalize() @@ -373,8 +373,13 @@ type Task struct { } func (t *Task) Canonicalize(tg *TaskGroup, job *Job) { - min := MinResources() - t.Resources.Canonicalize() + if t.Resources == nil { + var r Resources + r.Canonicalize() + t.Resources = &r + } else { + t.Resources.Canonicalize() + } if t.KillTimeout == nil { t.KillTimeout = helper.TimeToPtr(5 * time.Second)