From 9e6af2d7a49fc0dab7a4b0ea9c374887bc1259db Mon Sep 17 00:00:00 2001 From: Patrick Ohly Date: Fri, 4 Dec 2020 15:20:45 +0100 Subject: [PATCH] CSI mock driver: fix faulty error message Caught by verify-typecheck.sh after importing the code into Kubernetes: ERROR(linux/arm): /home/prow/go/src/k8s.io/kubernetes/_output/local/go/src/k8s.io/kubernetes/test/e2e/storage/drivers/csi-test/mock/service/controller.go:404:20: math.MaxUint32 (untyped int constant 4294967295) overflows int ERROR(linux/arm): /home/prow/go/src/k8s.io/kubernetes/_output/local/go/src/k8s.io/kubernetes/test/e2e/storage/drivers/csi-test/mock/service/controller.go:795:20: math.MaxUint32 (untyped int constant 4294967295) overflows int ERROR(linux/386): /home/prow/go/src/k8s.io/kubernetes/_output/local/go/src/k8s.io/kubernetes/test/e2e/storage/drivers/csi-test/mock/service/controller.go:404:20: math.MaxUint32 (untyped int constant 4294967295) overflows int ERROR(linux/386): /home/prow/go/src/k8s.io/kubernetes/_output/local/go/src/k8s.io/kubernetes/test/e2e/storage/drivers/csi-test/mock/service/controller.go:795:20: math.MaxUint32 (untyped int constant 4294967295) overflows int ERROR(windows/386): /home/prow/go/src/k8s.io/kubernetes/_output/local/go/src/k8s.io/kubernetes/test/e2e/storage/drivers/csi-test/mock/service/controller.go:404:20: math.MaxUint32 (untyped int constant 4294967295) overflows int ERROR(windows/386): /home/prow/go/src/k8s.io/kubernetes/_output/local/go/src/k8s.io/kubernetes/test/e2e/storage/drivers/csi-test/mock/service/controller.go:795:20: math.MaxUint32 (untyped int constant 4294967295) overflows int Instead of producing our own error message, we can show the original value and the error from strconv. --- mock/service/controller.go | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/mock/service/controller.go b/mock/service/controller.go index a8192fed..bf9b257c 100644 --- a/mock/service/controller.go +++ b/mock/service/controller.go @@ -2,7 +2,6 @@ package service import ( "fmt" - "math" "path" "reflect" "strconv" @@ -396,8 +395,8 @@ func (s *service) ListVolumes( if err != nil { return nil, status.Errorf( codes.Aborted, - "startingToken=%d !< int32=%d", - startingToken, math.MaxUint32) + "startingToken=%s: %v", + v, err) } startingToken = int32(i) } @@ -785,8 +784,8 @@ func getAllSnapshots(s *service, req *csi.ListSnapshotsRequest) (*csi.ListSnapsh if err != nil { return nil, status.Errorf( codes.Aborted, - "startingToken=%d !< int32=%d", - startingToken, math.MaxUint32) + "startingToken=%s: %v", + v, err) } startingToken = int32(i) }