Skip to content

Commit 66bb84d

Browse files
Jonathan S. Katzjkatz
authored andcommitted
Soften the display amounts for "pgo df"
While we will continue to "divide by 1024", if the remaining value is still over 1000, we will divide by 1024 again. It feels more natural to read "1GiB" instead of "1024MiB".
1 parent 7f0e366 commit 66bb84d

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

docs/content/releases/4.5.0.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,7 @@ To remove an annotation, one follows the format:
135135
- Any customizations for the cluster (e.g. custom PostgreSQL configuration) will be available.
136136
- This also fixes several bugs that were reported with the `pgo restore` functionality, some of which are captured further down in these release notes.
137137
- The [Downward API](https://kubernetes.io/docs/tasks/inject-data-application/downward-api-volume-expose-pod-information/) is now available to PostgreSQL instances.
138+
- The `pgo df` command will round values over 1000 up to the next unit type, e.g. `1GiB` instead of `1024MiB`.
138139

139140
## Fixes
140141

pgo/cmd/common.go

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -107,12 +107,11 @@ func getSizeAndUnit(size int64) (float64, unitType) {
107107
normalizedSize := float64(size)
108108

109109
// We keep dividing by "unitSize" which is 1024. Once it is less than the unit
110-
// size, that is the normalized unit we will use.
111-
// The astute observer will note that "du" returns in units of 1024, but we
112-
// want to attempt to keep things in the 3-digit area
110+
// size, or really, once it's less than "1000" of that unit size, that is
111+
// normalized unit we will use.
113112
//
114113
// of course, eventually this will get too big...so bail after yotta bytes
115-
for unit = unitB; normalizedSize > unitSize && unit < unitYB; unit++ {
114+
for unit = unitB; normalizedSize > 1000 && unit < unitYB; unit++ {
116115
normalizedSize /= unitSize
117116
}
118117

0 commit comments

Comments
 (0)