Skip to content

Commit

Permalink
cli: Handle nil MemoryMaxMB (#10620)
Browse files Browse the repository at this point in the history
Handle when MemoryMaxMB is nil, as expected when a new 1.1.0 is hitting
a pre-1.1.0 Server.
  • Loading branch information
Mahmood Ali committed May 19, 2021
1 parent 1e414a5 commit 97a0256
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 3 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
## 1.1.1 (Unreleased)

BUG FIXES:
* cli: Fixed a bug where `quota status` and `namespace status` commands may panic if the CLI targets a pre-1.1.0 cluster

## 1.1.0 (May 18, 2021)

FEATURES:
Expand Down
14 changes: 11 additions & 3 deletions command/quota_status.go
Original file line number Diff line number Diff line change
Expand Up @@ -189,9 +189,17 @@ func formatQuotaLimits(spec *api.QuotaSpec, usages map[string]*api.QuotaUsage) s
continue
}

cpu := fmt.Sprintf("%d / %s", *used.RegionLimit.CPU, formatQuotaLimitInt(specLimit.RegionLimit.CPU))
memory := fmt.Sprintf("%d / %s", *used.RegionLimit.MemoryMB, formatQuotaLimitInt(specLimit.RegionLimit.MemoryMB))
memoryMax := fmt.Sprintf("%d / %s", *used.RegionLimit.MemoryMaxMB, formatQuotaLimitInt(specLimit.RegionLimit.MemoryMaxMB))
orZero := func(v *int) int {
if v == nil {
return 0
}
return *v
}

cpu := fmt.Sprintf("%d / %s", orZero(used.RegionLimit.CPU), formatQuotaLimitInt(specLimit.RegionLimit.CPU))
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))
Expand Down

0 comments on commit 97a0256

Please sign in to comment.