From df6d3bc7dd1452400331d24bcfd012579375ce06 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. --- .../storage/drivers/csi-test/mock/service/controller.go | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/test/e2e/storage/drivers/csi-test/mock/service/controller.go b/test/e2e/storage/drivers/csi-test/mock/service/controller.go index 21fd2edc03c..7ff84d643b4 100644 --- a/test/e2e/storage/drivers/csi-test/mock/service/controller.go +++ b/test/e2e/storage/drivers/csi-test/mock/service/controller.go @@ -18,7 +18,6 @@ package service import ( "fmt" - "math" "path" "reflect" "strconv" @@ -412,8 +411,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) } @@ -801,8 +800,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) }