Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow omitting resource block entirely #1864

Merged
merged 2 commits into from
Oct 26, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

... and they will apply a default resource constraint of $x CPU and $y RAM ?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"CPU: 100, MemoryMB: 10" :)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes! Honestly this change is probably only useful for testing as the defaults really aren't intended to fit real world workflows.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

would be nice if nomad could emit plan/run warnings saying "you did stupid shit, stop doing it, but i will do it anyway since I'm a cool nomad scheduler"


## 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 @@ -2103,7 +2103,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 {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add a comment

t.Resources = DefaultResources()
} else {
t.Resources.Canonicalize()
}

Expand Down Expand Up @@ -2155,12 +2158,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