Skip to content

Commit

Permalink
Warn if IOPS is being used
Browse files Browse the repository at this point in the history
  • Loading branch information
dadgar committed Dec 7, 2018
1 parent 0953d91 commit f555dc3
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 0 deletions.
1 change: 1 addition & 0 deletions command/agent/job_endpoint.go
Original file line number Diff line number Diff line change
Expand Up @@ -853,6 +853,7 @@ func ApiResourcesToStructs(in *api.Resources) *structs.Resources {
out := &structs.Resources{
CPU: *in.CPU,
MemoryMB: *in.MemoryMB,
IOPS: *in.IOPS, // COMPAT(0.10): Only being used to issue warnings
}

if l := len(in.Networks); l != 0 {
Expand Down
19 changes: 19 additions & 0 deletions nomad/structs/structs.go
Original file line number Diff line number Diff line change
Expand Up @@ -1698,6 +1698,7 @@ type Resources struct {
CPU int
MemoryMB int
DiskMB int
IOPS int // COMPAT(0.10): Only being used to issue warnings
Networks Networks
Devices []*RequestedDevice
}
Expand Down Expand Up @@ -4663,6 +4664,13 @@ func (tg *TaskGroup) Warnings(j *Job) error {
}
}

for _, t := range tg.Tasks {
if err := t.Warnings(); err != nil {
err = multierror.Prefix(err, fmt.Sprintf("Task %q:", t.Name))
mErr.Errors = append(mErr.Errors, err)
}
}

return mErr.ErrorOrNil()
}

Expand Down Expand Up @@ -5506,6 +5514,17 @@ func validateServices(t *Task) error {
return mErr.ErrorOrNil()
}

func (t *Task) Warnings() error {
var mErr multierror.Error

// Validate the resources
if t.Resources != nil && t.Resources.IOPS != 0 {
mErr.Errors = append(mErr.Errors, fmt.Errorf("IOPS has been deprecated as of Nomad 0.9.0. Please remove IOPS from resource stanza."))
}

return mErr.ErrorOrNil()
}

const (
// TemplateChangeModeNoop marks that no action should be taken if the
// template is re-rendered
Expand Down

0 comments on commit f555dc3

Please sign in to comment.