From f555dc3f67730afc2cbb54aaba70aa80d6118ac8 Mon Sep 17 00:00:00 2001 From: Alex Dadgar <alex.dadgar@gmail.com> Date: Thu, 6 Dec 2018 16:17:09 -0800 Subject: [PATCH] Warn if IOPS is being used --- command/agent/job_endpoint.go | 1 + nomad/structs/structs.go | 19 +++++++++++++++++++ 2 files changed, 20 insertions(+) diff --git a/command/agent/job_endpoint.go b/command/agent/job_endpoint.go index c34204cc2a..8414eac2fc 100644 --- a/command/agent/job_endpoint.go +++ b/command/agent/job_endpoint.go @@ -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 { diff --git a/nomad/structs/structs.go b/nomad/structs/structs.go index 922ae84ad8..3d081cc840 100644 --- a/nomad/structs/structs.go +++ b/nomad/structs/structs.go @@ -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 } @@ -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() } @@ -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 -- GitLab