mirror of
https://github.com/kemko/nomad.git
synced 2026-01-07 19:05:42 +03:00
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.
This commit is contained in:
11
api/tasks.go
11
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)
|
||||
|
||||
Reference in New Issue
Block a user