From 261adf0b4d767aab101cc99036485ed4352bd0af Mon Sep 17 00:00:00 2001 From: Nick Ethier Date: Thu, 24 Sep 2020 11:44:59 -0400 Subject: [PATCH] command: remove mbits from quota hcl (#8740) --- command/quota_apply.go | 17 --------------- command/quota_apply_test.go | 41 ------------------------------------- command/quota_init.go | 8 +------- 3 files changed, 1 insertion(+), 65 deletions(-) diff --git a/command/quota_apply.go b/command/quota_apply.go index 80b05c6a4..0dee1519d 100644 --- a/command/quota_apply.go +++ b/command/quota_apply.go @@ -13,7 +13,6 @@ import ( "github.com/hashicorp/hcl/hcl/ast" "github.com/hashicorp/nomad/api" "github.com/hashicorp/nomad/helper" - "github.com/hashicorp/nomad/jobspec" "github.com/mitchellh/mapstructure" "github.com/posener/complete" ) @@ -262,7 +261,6 @@ func parseQuotaResource(result *api.Resources, list *ast.ObjectList) error { valid := []string{ "cpu", "memory", - "network", } if err := helper.CheckHCLKeys(listVal, valid); err != nil { return multierror.Prefix(err, "resources ->") @@ -277,20 +275,5 @@ func parseQuotaResource(result *api.Resources, list *ast.ObjectList) error { return err } - // Find the network ObjectList, parse it - nw := listVal.Filter("network") - if len(nw.Items) > 0 { - rl, err := jobspec.ParseNetwork(nw) - if err != nil { - return multierror.Prefix(err, "resources ->") - } - if rl != nil { - if rl.Mode != "" || rl.HasPorts() { - return fmt.Errorf("resources -> network only allows mbits") - } - result.Networks = []*api.NetworkResource{rl} - } - } - return nil } diff --git a/command/quota_apply_test.go b/command/quota_apply_test.go index 31d70f2d7..4af13cffc 100644 --- a/command/quota_apply_test.go +++ b/command/quota_apply_test.go @@ -4,9 +4,7 @@ import ( "strings" "testing" - "github.com/hashicorp/nomad/api" "github.com/mitchellh/cli" - "github.com/stretchr/testify/require" ) func TestQuotaApplyCommand_Implements(t *testing.T) { @@ -36,42 +34,3 @@ func TestQuotaApplyCommand_Fails(t *testing.T) { } ui.ErrorWriter.Reset() } - -func TestQuotaApplyNetwork(t *testing.T) { - t.Parallel() - - mbits := 20 - - cases := []struct { - hcl string - q *api.QuotaSpec - err string - }{{ - hcl: `limit {region = "global", region_limit {network {mbits = 20}}}`, - q: &api.QuotaSpec{ - Limits: []*api.QuotaLimit{{ - Region: "global", - RegionLimit: &api.Resources{ - Networks: []*api.NetworkResource{{ - MBits: &mbits, - }}, - }, - }}, - }, - err: "", - }, { - hcl: `limit {region = "global", region_limit {network { mbits = 20, device = "eth0"}}}`, - q: nil, - err: "network -> invalid key: device", - }} - - for _, c := range cases { - t.Run(c.hcl, func(t *testing.T) { - q, err := parseQuotaSpec([]byte(c.hcl)) - require.Equal(t, c.q, q) - if c.err != "" { - require.Contains(t, err.Error(), c.err) - } - }) - } -} diff --git a/command/quota_init.go b/command/quota_init.go index 45d712591..a78a356c7 100644 --- a/command/quota_init.go +++ b/command/quota_init.go @@ -115,9 +115,6 @@ limit { region_limit { cpu = 2500 memory = 1000 - network { - mbits = 50 - } } } `) @@ -131,10 +128,7 @@ var defaultJsonQuotaSpec = strings.TrimSpace(` "Region": "global", "RegionLimit": { "CPU": 2500, - "MemoryMB": 1000, - "Networks": [ - { "MBits": 50 } - ] + "MemoryMB": 1000 } } ]