Skip to content

Commit

Permalink
cli: remove network from quota status output (#14468)
Browse files Browse the repository at this point in the history
Network quotas were removed in Nomad 1.0.4. Remove the fields no longer in use
from the `quota status` output.
  • Loading branch information
tgross authored Sep 6, 2022
1 parent 08de94b commit bbd87ee
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 14 deletions.
3 changes: 3 additions & 0 deletions .changelog/14468.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
```release-note:improvement
cli: Removed deprecated network quota fields from `quota status` output
```
17 changes: 3 additions & 14 deletions command/quota_status.go
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ func formatQuotaLimits(spec *api.QuotaSpec, usages map[string]*api.QuotaUsage) s
sort.Sort(api.QuotaLimitSort(spec.Limits))

limits := make([]string, len(spec.Limits)+1)
limits[0] = "Region|CPU Usage|Memory Usage|Memory Max Usage|Network Usage|Variables Usage"
limits[0] = "Region|CPU Usage|Memory Usage|Memory Max Usage|Variables Usage"
i := 0
for _, specLimit := range spec.Limits {
i++
Expand All @@ -174,20 +174,14 @@ func formatQuotaLimits(spec *api.QuotaSpec, usages map[string]*api.QuotaUsage) s
return used, ok
}

specBits := 0
if len(specLimit.RegionLimit.Networks) == 1 {
specBits = *specLimit.RegionLimit.Networks[0].MBits
}

used, ok := lookupUsage()
if !ok {
cpu := fmt.Sprintf("- / %s", formatQuotaLimitInt(specLimit.RegionLimit.CPU))
memory := fmt.Sprintf("- / %s", formatQuotaLimitInt(specLimit.RegionLimit.MemoryMB))
memoryMax := fmt.Sprintf("- / %s", formatQuotaLimitInt(specLimit.RegionLimit.MemoryMaxMB))
net := fmt.Sprintf("- / %s", formatQuotaLimitInt(&specBits))

vars := fmt.Sprintf("- / %s", formatQuotaLimitInt(specLimit.VariablesLimit))
limits[i] = fmt.Sprintf("%s|%s|%s|%s|%s|%s", specLimit.Region, cpu, memory, memoryMax, net, vars)
limits[i] = fmt.Sprintf("%s|%s|%s|%s|%s", specLimit.Region, cpu, memory, memoryMax, vars)
continue
}

Expand All @@ -202,13 +196,8 @@ func formatQuotaLimits(spec *api.QuotaSpec, usages map[string]*api.QuotaUsage) s
memory := fmt.Sprintf("%d / %s", orZero(used.RegionLimit.MemoryMB), formatQuotaLimitInt(specLimit.RegionLimit.MemoryMB))
memoryMax := fmt.Sprintf("%d / %s", orZero(used.RegionLimit.MemoryMaxMB), formatQuotaLimitInt(specLimit.RegionLimit.MemoryMaxMB))

net := fmt.Sprintf("- / %s", formatQuotaLimitInt(&specBits))
if len(used.RegionLimit.Networks) == 1 {
net = fmt.Sprintf("%d / %s", *used.RegionLimit.Networks[0].MBits, formatQuotaLimitInt(&specBits))
}

vars := fmt.Sprintf("%d / %s", orZero(used.VariablesLimit), formatQuotaLimitInt(specLimit.VariablesLimit))
limits[i] = fmt.Sprintf("%s|%s|%s|%s|%s|%s", specLimit.Region, cpu, memory, memoryMax, net, vars)
limits[i] = fmt.Sprintf("%s|%s|%s|%s|%s", specLimit.Region, cpu, memory, memoryMax, vars)
}

return formatList(limits)
Expand Down

0 comments on commit bbd87ee

Please sign in to comment.