Skip to content

Commit

Permalink
Merge pull request #1864 from hashicorp/b-allow-empty-resource
Browse files Browse the repository at this point in the history
Allow omitting resource block entirely
  • Loading branch information
schmichael committed Oct 26, 2016
2 parents 28b4eef + ea963ab commit 00a816c
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 6 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ BUG FIXES:
the client [GH-1641]
* discovery/jobspec: Validate service name after interpolation [GH-1852]
* driver/docker: Fix `local/` directory mount into container [GH-1830]
* jobspec: Tasks without a resource block no longer fail to validate [GH-1864]

## 0.4.1 (August 18, 2016)

Expand Down
15 changes: 9 additions & 6 deletions nomad/structs/structs.go
Original file line number Diff line number Diff line change
Expand Up @@ -2106,7 +2106,10 @@ func (t *Task) Canonicalize(job *Job, tg *TaskGroup) {
service.Canonicalize(job.Name, tg.Name, t.Name)
}

if t.Resources != nil {
// If Resources are nil initialize them to defaults, otherwise canonicalize
if t.Resources == nil {
t.Resources = DefaultResources()
} else {
t.Resources.Canonicalize()
}

Expand Down Expand Up @@ -2158,12 +2161,12 @@ func (t *Task) Validate(ephemeralDisk *EphemeralDisk) error {
// Validate the resources.
if t.Resources == nil {
mErr.Errors = append(mErr.Errors, errors.New("Missing task resources"))
} else if err := t.Resources.MeetsMinResources(); err != nil {
mErr.Errors = append(mErr.Errors, err)
}
} else {
if err := t.Resources.MeetsMinResources(); err != nil {
mErr.Errors = append(mErr.Errors, err)
}

// Ensure the task isn't asking for disk resources
if t.Resources != nil {
// Ensure the task isn't asking for disk resources
if t.Resources.DiskMB > 0 {
mErr.Errors = append(mErr.Errors, errors.New("Task can't ask for disk resources, they have to be specified at the task group level."))
}
Expand Down

0 comments on commit 00a816c

Please sign in to comment.