Skip to content

Commit ed344e7

Browse files
committed
Overflow errors look weird in string format
before: quantity {{0 0} {0xc000cf77d0} DecimalSI} is too great, overflows int64 after: quantity 73786976299133170k is too great, overflows int64
1 parent 6c9aab2 commit ed344e7

File tree

1 file changed

+10
-10
lines changed
  • staging/src/k8s.io/cloud-provider/volume/helpers

1 file changed

+10
-10
lines changed

staging/src/k8s.io/cloud-provider/volume/helpers/rounding.go

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ const (
4343
func RoundUpToGiB(size resource.Quantity) (int64, error) {
4444
requestBytes, ok := size.AsInt64()
4545
if !ok {
46-
return 0, fmt.Errorf("quantity %v is too great, overflows int64", size)
46+
return 0, fmt.Errorf("quantity %s is too great, overflows int64", size.String())
4747
}
4848
return roundUpSize(requestBytes, GiB), nil
4949
}
@@ -52,7 +52,7 @@ func RoundUpToGiB(size resource.Quantity) (int64, error) {
5252
func RoundUpToMB(size resource.Quantity) (int64, error) {
5353
requestBytes, ok := size.AsInt64()
5454
if !ok {
55-
return 0, fmt.Errorf("quantity %v is too great, overflows int64", size)
55+
return 0, fmt.Errorf("quantity %s is too great, overflows int64", size.String())
5656
}
5757
return roundUpSize(requestBytes, MB), nil
5858
}
@@ -61,7 +61,7 @@ func RoundUpToMB(size resource.Quantity) (int64, error) {
6161
func RoundUpToMiB(size resource.Quantity) (int64, error) {
6262
requestBytes, ok := size.AsInt64()
6363
if !ok {
64-
return 0, fmt.Errorf("quantity %v is too great, overflows int64", size)
64+
return 0, fmt.Errorf("quantity %s is too great, overflows int64", size.String())
6565
}
6666
return roundUpSize(requestBytes, MiB), nil
6767
}
@@ -70,7 +70,7 @@ func RoundUpToMiB(size resource.Quantity) (int64, error) {
7070
func RoundUpToKB(size resource.Quantity) (int64, error) {
7171
requestBytes, ok := size.AsInt64()
7272
if !ok {
73-
return 0, fmt.Errorf("quantity %v is too great, overflows int64", size)
73+
return 0, fmt.Errorf("quantity %s is too great, overflows int64", size.String())
7474
}
7575
return roundUpSize(requestBytes, KB), nil
7676
}
@@ -79,7 +79,7 @@ func RoundUpToKB(size resource.Quantity) (int64, error) {
7979
func RoundUpToKiB(size resource.Quantity) (int64, error) {
8080
requestBytes, ok := size.AsInt64()
8181
if !ok {
82-
return 0, fmt.Errorf("quantity %v is too great, overflows int64", size)
82+
return 0, fmt.Errorf("quantity %s is too great, overflows int64", size.String())
8383
}
8484
return roundUpSize(requestBytes, KiB), nil
8585
}
@@ -89,7 +89,7 @@ func RoundUpToKiB(size resource.Quantity) (int64, error) {
8989
func RoundUpToGiBInt(size resource.Quantity) (int, error) {
9090
requestBytes, ok := size.AsInt64()
9191
if !ok {
92-
return 0, fmt.Errorf("quantity %v is too great, overflows int64", size)
92+
return 0, fmt.Errorf("quantity %s is too great, overflows int64", size.String())
9393
}
9494
return roundUpSizeInt(requestBytes, GiB)
9595
}
@@ -99,7 +99,7 @@ func RoundUpToGiBInt(size resource.Quantity) (int, error) {
9999
func RoundUpToMBInt(size resource.Quantity) (int, error) {
100100
requestBytes, ok := size.AsInt64()
101101
if !ok {
102-
return 0, fmt.Errorf("quantity %v is too great, overflows int64", size)
102+
return 0, fmt.Errorf("quantity %s is too great, overflows int64", size.String())
103103
}
104104
return roundUpSizeInt(requestBytes, MB)
105105
}
@@ -109,7 +109,7 @@ func RoundUpToMBInt(size resource.Quantity) (int, error) {
109109
func RoundUpToMiBInt(size resource.Quantity) (int, error) {
110110
requestBytes, ok := size.AsInt64()
111111
if !ok {
112-
return 0, fmt.Errorf("quantity %v is too great, overflows int64", size)
112+
return 0, fmt.Errorf("quantity %s is too great, overflows int64", size.String())
113113
}
114114
return roundUpSizeInt(requestBytes, MiB)
115115
}
@@ -119,7 +119,7 @@ func RoundUpToMiBInt(size resource.Quantity) (int, error) {
119119
func RoundUpToKBInt(size resource.Quantity) (int, error) {
120120
requestBytes, ok := size.AsInt64()
121121
if !ok {
122-
return 0, fmt.Errorf("quantity %v is too great, overflows int64", size)
122+
return 0, fmt.Errorf("quantity %s is too great, overflows int64", size.String())
123123
}
124124
return roundUpSizeInt(requestBytes, KB)
125125
}
@@ -136,7 +136,7 @@ func RoundUpToKiBInt(size resource.Quantity) (int, error) {
136136
func RoundUpToGiBInt32(size resource.Quantity) (int32, error) {
137137
requestBytes, ok := size.AsInt64()
138138
if !ok {
139-
return 0, fmt.Errorf("quantity %v is too great, overflows int64", size)
139+
return 0, fmt.Errorf("quantity %s is too great, overflows int64", size.String())
140140
}
141141
return roundUpSizeInt32(requestBytes, GiB)
142142
}

0 commit comments

Comments
 (0)