Repository: kubernetes-csi/external-provisioner
Pull request #541 (2020-12-17 01:54:59)

fix volume size mismatch between driver and PV
<!--  Thanks for sending a pull request!  Here are some tips for you:

1. If this is your first time, please read our contributor guidelines: https://git.k8s.io/community/contributors/guide#your-first-contribution and developer guide https://git.k8s.io/community/contributors/devel/development.md#development-guide
2. Follow the instructions for writing a release note: https://git.k8s.io/community/contributors/guide/release-notes.md
3. If the PR is unfinished, see how to mark it: https://git.k8s.io/community/contributors/guide/pull-requests.md#marking-unfinished-pull-requests
-->

**What type of PR is this?**
/kind bug

**What this PR does / why we need it**:
Fix the issue where csi provisioner does not honor the volume size returned from CreateVolumeResponse.

**Which issue(s) this PR fixes**:
<!--
*Automatically closes linked issue when PR is merged.
Usage: `Fixes #<issue number>`, or `Fixes (paste link of issue)`.
_If PR is about `failing-tests or flakes`, please post the related issues/tests in a comment and do not use `Fixes`_*
-->
Fixes # https://github.com/kubernetes-csi/external-provisioner/issues/199

**Special notes for your reviewer**:

**Does this PR introduce a user-facing change?**:
<!--
If no, just write "NONE" in the release-note block below.
If yes, a release note is required:
Enter your extended release note in the block below. If the PR requires additional action from users switching to the new release, include the string "action required".
-->
```release-note
Fix an issue where the csi-provisioner does not honor the volume size returned from CreateVolumeResponse. Stop rounding up bytes returned from CreateVolume.
```

/cc @msau42 
/cc @wongma7 


Patch:
diff --git a/README.md b/README.md
index 3f537d520..6759fa150 100644
--- a/README.md
+++ b/README.md
@@ -74,7 +74,7 @@ Note that the external-provisioner does not scale with more replicas. Only one e
 
 See the [storage capacity section](#capacity-support) below for details.
 
-* `--enable-capacity`: This enables producing CSIStorageCapacity objects with capacity information from the driver's GetCapacity call. The default is to not produce CSIStorageCapacity objects.
+* `--capacity-controller-deployment-mode=central|local`: Setting this enables producing CSIStorageCapacity objects with capacity information from the driver's GetCapacity call. Use `central` when there is just one active external-provisioner in the cluster. Use `local` when deploying external-provisioner on each node with distributed provisioning. The default is to not produce CSIStorageCapacity objects.
 
 * `--capacity-ownerref-level <levels>`: The level indicates the number of objects that need to be traversed starting from the pod identified by the POD_NAME and POD_NAMESPACE environment variables to reach the owning object for CSIStorageCapacity objects: 0 for the pod itself, 1 for a StatefulSet, 2 for a Deployment, etc. Defaults to `1` (= StatefulSet).
 
@@ -165,7 +165,7 @@ example):
         fieldRef:
         fieldPath: metadata.name
 ```
-- Add `--enable-capacity` to the command line flags.
+- Add `--capacity-controller-deployment-mode=central` to the command line flags.
 - Add `StorageCapacity: true` to the CSIDriver information object.
   Without it, external-provisioner will publish information, but the
   Kubernetes scheduler will ignore it. This can be used to first
@@ -232,7 +232,8 @@ other driver.
 
 The deployment with [distributed
 provisioning](#distributed-provisioning) is almost the same as above,
-with some minor change:
+with some minor changes:
+- Add `--capacity-controller-deployment-mode=local` to the command line flags.
 - Use `--capacity-ownerref-level=0` and the `POD_NAMESPACE/POD_NAME`
   variables to make the pod that contains the external-provisioner
   the owner of CSIStorageCapacity objects for the node.
diff --git a/cmd/csi-provisioner/csi-provisioner.go b/cmd/csi-provisioner/csi-provisioner.go
index 18ddc97cc..4c33b43e8 100644
--- a/cmd/csi-provisioner/csi-provisioner.go
+++ b/cmd/csi-provisioner/csi-provisioner.go
@@ -84,7 +84,11 @@ var (
 	kubeAPIQPS   = flag.Float32("kube-api-qps", 5, "QPS to use while communicating with the kubernetes apiserver. Defaults to 5.0.")
 	kubeAPIBurst = flag.Int("kube-api-burst", 10, "Burst to use while communicating with the kubernetes apiserver. Defaults to 10.")
 
-	enableCapacity           = flag.Bool("enable-capacity", false, "This enables producing CSIStorageCapacity objects with capacity information from the driver's GetCapacity call.")
+	capacityMode = func() *capacity.DeploymentMode {
+		mode := capacity.DeploymentModeUnset
+		flag.Var(&mode, "capacity-controller-deployment-mode", "Setting this enables producing CSIStorageCapacity objects with capacity information from the driver's GetCapacity call. 'central' is currently the only supported mode. Use it when there is just one active provisioner in the cluster.")
+		return &mode
+	}()
 	capacityImmediateBinding = flag.Bool("capacity-for-immediate-binding", false, "Enables producing capacity information for storage classes with immediate binding. Not needed for the Kubernetes scheduler, maybe useful for other consumers or for debugging.")
 	capacityPollInterval     = flag.Duration("capacity-poll-interval", time.Minute, "How long the external-provisioner waits before checking for storage capacity changes.")
 	capacityOwnerrefLevel    = flag.Int("capacity-ownerref-level", 1, "The level indicates the number of objects that need to be traversed starting from the pod identified by the POD_NAME and POD_NAMESPACE environment variables to reach the owning object for CSIStorageCapacity objects: 0 for the pod itself, 1 for a StatefulSet, 2 for a Deployment, etc.")
@@ -382,7 +386,8 @@ func main() {
 	)
 
 	var capacityController *capacity.Controller
-	if *enableCapacity {
+	if *capacityMode == capacity.DeploymentModeCentral ||
+		*capacityMode == capacity.DeploymentModeLocal {
 		podName := os.Getenv("POD_NAME")
 		namespace := os.Getenv("POD_NAMESPACE")
 		if podName == "" || namespace == "" {
@@ -400,7 +405,7 @@ func main() {
 		klog.Infof("using %s/%s %s as owner of CSIStorageCapacity objects", controller.APIVersion, controller.Kind, controller.Name)
 
 		var topologyInformer topology.Informer
-		if nodeDeployment == nil {
+		if *capacityMode == capacity.DeploymentModeCentral {
 			topologyInformer = topology.NewNodeTopology(
 				provisionerName,
 				clientset,
@@ -410,6 +415,9 @@ func main() {
 			)
 		} else {
 			var segment topology.Segment
+			if nodeDeployment == nil {
+				klog.Fatal("--capacity-controller-deployment-mode=local is only valid in combination with --node-deployment")
+			}
 			if nodeDeployment.NodeInfo.AccessibleTopology != nil {
 				for key, value := range nodeDeployment.NodeInfo.AccessibleTopology.Segments {
 					segment = append(segment, topology.SegmentEntry{Key: key, Value: value})
diff --git a/pkg/capacity/mode.go b/pkg/capacity/mode.go
new file mode 100644
index 000000000..9817a8c04
--- /dev/null
+++ b/pkg/capacity/mode.go
@@ -0,0 +1,63 @@
+/*
+Copyright 2020 The Kubernetes Authors.
+
+Licensed under the Apache License, Version 2.0 (the "License");
+you may not use this file except in compliance with the License.
+You may obtain a copy of the License at
+
+    http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing, software
+distributed under the License is distributed on an "AS IS" BASIS,
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+See the License for the specific language governing permissions and
+limitations under the License.
+*/
+
+package capacity
+
+import (
+	"errors"
+	"strings"
+
+	flag "github.com/spf13/pflag"
+)
+
+// DeploymentMode determines how the capacity controller operates.
+type DeploymentMode string
+
+const (
+	// DeploymentModeCentral enables the mode where there is only one
+	// external-provisioner actively running in the cluster which
+	// talks to the CSI driver's controller service.
+	DeploymentModeCentral = DeploymentMode("central")
+
+	// DeploymentModeLocal enables the mode where external-provisioner
+	// is deployed on each node.
+	DeploymentModeLocal = DeploymentMode("local")
+
+	// DeploymentModeUnset disables the capacity feature completely.
+	DeploymentModeUnset = DeploymentMode("")
+)
+
+// Set enables the named features. Multiple features can be listed, separated by commas,
+// with optional whitespace.
+func (mode *DeploymentMode) Set(value string) error {
+	switch DeploymentMode(value) {
+	case DeploymentModeCentral, DeploymentModeLocal, DeploymentModeUnset:
+		*mode = DeploymentMode(value)
+	default:
+		return errors.New("invalid value")
+	}
+	return nil
+}
+
+func (mode *DeploymentMode) String() string {
+	return string(*mode)
+}
+
+func (mode *DeploymentMode) Type() string {
+	return strings.Join([]string{string(DeploymentModeCentral), string(DeploymentModeLocal)}, "|")
+}
+
+var _ flag.Value = new(DeploymentMode)
diff --git a/pkg/controller/controller.go b/pkg/controller/controller.go
index f97abe54a..200f30c53 100644
--- a/pkg/controller/controller.go
+++ b/pkg/controller/controller.go
@@ -20,7 +20,6 @@ import (
 	"context"
 	"errors"
 	"fmt"
-	"math"
 	"os"
 	"strings"
 	"time"
@@ -810,7 +809,7 @@ func (p *csiProvisioner) Provision(ctx context.Context, options controller.Provi
 			AccessModes:  options.PVC.Spec.AccessModes,
 			MountOptions: options.StorageClass.MountOptions,
 			Capacity: v1.ResourceList{
-				v1.ResourceName(v1.ResourceStorage): bytesToGiQuantity(respCap),
+				v1.ResourceName(v1.ResourceStorage): bytesToQuantity(respCap),
 			},
 			// TODO wait for CSI VolumeSource API
 			PersistentVolumeSource: v1.PersistentVolumeSource{
@@ -1641,24 +1640,9 @@ func getCredentials(ctx context.Context, k8s kubernetes.Interface, ref *v1.Secre
 	return credentials, nil
 }
 
-func bytesToGiQuantity(bytes int64) resource.Quantity {
-	var num int64
-	var floatBytes, MiB, GiB float64
-	var suffix string
-	floatBytes = float64(bytes)
-	MiB = 1024 * 1024
-	GiB = MiB * 1024
-	// Need to give Quantity nice whole numbers or else it
-	// sometimes spits out the value in milibytes. We round up.
-	if floatBytes < GiB {
-		num = int64(math.Ceil(floatBytes / MiB))
-		suffix = "Mi"
-	} else {
-		num = int64(math.Ceil(floatBytes / GiB))
-		suffix = "Gi"
-	}
-	stringQuantity := fmt.Sprintf("%v%s", num, suffix)
-	return resource.MustParse(stringQuantity)
+func bytesToQuantity(bytes int64) resource.Quantity {
+	quantity := resource.NewQuantity(bytes, resource.BinarySI)
+	return *quantity
 }
 
 func deprecationWarning(deprecatedParam, newParam, removalVersion string) string {


Test patch:
diff --git a/pkg/controller/controller_test.go b/pkg/controller/controller_test.go
index dd2b338ae..e5805dc09 100644
--- a/pkg/controller/controller_test.go
+++ b/pkg/controller/controller_test.go
@@ -361,14 +361,14 @@ func TestBytesToQuantity(t *testing.T) {
 		quantString string
 	}{
 		{
-			"Gibibyte rounding up from above .5",
+			"Gibibyte that cannot be put into any nice format without loss precision",
 			5.56 * 1024 * 1024 * 1024,
-			"6Gi",
+			"5970004541",
 		},
 		{
-			"Gibibyte rounding up from below .5",
-			5.23 * 1024 * 1024 * 1024,
-			"6Gi",
+			"Gibibyte that can be parsed nicer",
+			5.5 * 1024 * 1024 * 1024,
+			"5632Mi",
 		},
 		{
 			"Gibibyte exact",
@@ -376,20 +376,20 @@ func TestBytesToQuantity(t *testing.T) {
 			"5Gi",
 		},
 		{
-			"Mebibyte rounding up from below .5",
+			"Mebibyte that cannot be parsed nicer",
 			5.23 * 1024 * 1024,
-			"6Mi",
+			"5484052",
 		},
 		{
-			"Mebibyte/Gibibyte barrier (Quantity type rounds this)",
-			// (1024 * 1024 * 1024) - 1
-			1073741823,
-			"1Gi",
+			"Kibibyte that can be parsed nicer",
+			// (100 * 1024)
+			102400,
+			"100Ki",
 		},
 	}
 
 	for _, test := range tests {
-		q := bytesToGiQuantity(int64(test.bytes))
+		q := bytesToQuantity(int64(test.bytes))
 		if q.String() != test.quantString {
 			t.Errorf("test: %s, expected: %v, got: %v", test.testName, test.quantString, q.String())
 		}
@@ -907,7 +907,7 @@ func TestFSTypeProvision(t *testing.T) {
 				Name:          "test-testi",
 				ReclaimPolicy: v1.PersistentVolumeReclaimDelete,
 				Capacity: v1.ResourceList{
-					v1.ResourceName(v1.ResourceStorage): bytesToGiQuantity(requestedBytes),
+					v1.ResourceName(v1.ResourceStorage): bytesToQuantity(requestedBytes),
 				},
 				CSIPVS: &v1.CSIPersistentVolumeSource{
 					Driver:       "test-driver",
@@ -935,7 +935,7 @@ func TestFSTypeProvision(t *testing.T) {
 				Name:          "test-testi",
 				ReclaimPolicy: v1.PersistentVolumeReclaimDelete,
 				Capacity: v1.ResourceList{
-					v1.ResourceName(v1.ResourceStorage): bytesToGiQuantity(requestedBytes),
+					v1.ResourceName(v1.ResourceStorage): bytesToQuantity(requestedBytes),
 				},
 				CSIPVS: &v1.CSIPersistentVolumeSource{
 					Driver:       "test-driver",
@@ -966,7 +966,7 @@ func TestFSTypeProvision(t *testing.T) {
 				Name:          "test-testi",
 				ReclaimPolicy: v1.PersistentVolumeReclaimDelete,
 				Capacity: v1.ResourceList{
-					v1.ResourceName(v1.ResourceStorage): bytesToGiQuantity(requestedBytes),
+					v1.ResourceName(v1.ResourceStorage): bytesToQuantity(requestedBytes),
 				},
 				CSIPVS: &v1.CSIPersistentVolumeSource{
 					Driver:       "test-driver",
@@ -996,7 +996,7 @@ func TestFSTypeProvision(t *testing.T) {
 				Name:          "test-testi",
 				ReclaimPolicy: v1.PersistentVolumeReclaimDelete,
 				Capacity: v1.ResourceList{
-					v1.ResourceName(v1.ResourceStorage): bytesToGiQuantity(requestedBytes),
+					v1.ResourceName(v1.ResourceStorage): bytesToQuantity(requestedBytes),
 				},
 				CSIPVS: &v1.CSIPersistentVolumeSource{
 					Driver:       "test-driver",
@@ -1049,7 +1049,7 @@ func TestProvision(t *testing.T) {
 				Name:          "test-testi",
 				ReclaimPolicy: v1.PersistentVolumeReclaimDelete,
 				Capacity: v1.ResourceList{
-					v1.ResourceName(v1.ResourceStorage): bytesToGiQuantity(requestedBytes),
+					v1.ResourceName(v1.ResourceStorage): bytesToQuantity(requestedBytes),
 				},
 				CSIPVS: &v1.CSIPersistentVolumeSource{
 					Driver:       "test-driver",
@@ -1078,7 +1078,7 @@ func TestProvision(t *testing.T) {
 				Name:          "test-testi",
 				ReclaimPolicy: v1.PersistentVolumeReclaimDelete,
 				Capacity: v1.ResourceList{
-					v1.ResourceName(v1.ResourceStorage): bytesToGiQuantity(requestedBytes),
+					v1.ResourceName(v1.ResourceStorage): bytesToQuantity(requestedBytes),
 				},
 				CSIPVS: &v1.CSIPersistentVolumeSource{
 					Driver:       "test-driver",
@@ -1133,7 +1133,7 @@ func TestProvision(t *testing.T) {
 				Name:          "test-testi",
 				ReclaimPolicy: v1.PersistentVolumeReclaimDelete,
 				Capacity: v1.ResourceList{
-					v1.ResourceName(v1.ResourceStorage): bytesToGiQuantity(requestedBytes),
+					v1.ResourceName(v1.ResourceStorage): bytesToQuantity(requestedBytes),
 				},
 				CSIPVS: &v1.CSIPersistentVolumeSource{
 					Driver:       "test-driver",
@@ -1179,7 +1179,7 @@ func TestProvision(t *testing.T) {
 				ReclaimPolicy: v1.PersistentVolumeReclaimDelete,
 				AccessModes:   []v1.PersistentVolumeAccessMode{v1.ReadWriteMany},
 				Capacity: v1.ResourceList{
-					v1.ResourceName(v1.ResourceStorage): bytesToGiQuantity(requestedBytes),
+					v1.ResourceName(v1.ResourceStorage): bytesToQuantity(requestedBytes),
 				},
 				CSIPVS: &v1.CSIPersistentVolumeSource{
 					Driver:       "test-driver",
@@ -1231,7 +1231,7 @@ func TestProvision(t *testing.T) {
 				ReclaimPolicy: v1.PersistentVolumeReclaimDelete,
 				AccessModes:   []v1.PersistentVolumeAccessMode{v1.ReadOnlyMany},
 				Capacity: v1.ResourceList{
-					v1.ResourceName(v1.ResourceStorage): bytesToGiQuantity(requestedBytes),
+					v1.ResourceName(v1.ResourceStorage): bytesToQuantity(requestedBytes),
 				},
 				CSIPVS: &v1.CSIPersistentVolumeSource{
 					Driver:       "test-driver",
@@ -1283,7 +1283,7 @@ func TestProvision(t *testing.T) {
 				ReclaimPolicy: v1.PersistentVolumeReclaimDelete,
 				AccessModes:   []v1.PersistentVolumeAccessMode{v1.ReadWriteOnce},
 				Capacity: v1.ResourceList{
-					v1.ResourceName(v1.ResourceStorage): bytesToGiQuantity(requestedBytes),
+					v1.ResourceName(v1.ResourceStorage): bytesToQuantity(requestedBytes),
 				},
 				CSIPVS: &v1.CSIPersistentVolumeSource{
 					Driver:       "test-driver",
@@ -1335,7 +1335,7 @@ func TestProvision(t *testing.T) {
 				ReclaimPolicy: v1.PersistentVolumeReclaimDelete,
 				AccessModes:   []v1.PersistentVolumeAccessMode{v1.ReadOnlyMany, v1.ReadWriteOnce},
 				Capacity: v1.ResourceList{
-					v1.ResourceName(v1.ResourceStorage): bytesToGiQuantity(requestedBytes),
+					v1.ResourceName(v1.ResourceStorage): bytesToQuantity(requestedBytes),
 				},
 				CSIPVS: &v1.CSIPersistentVolumeSource{
 					Driver:       "test-driver",
@@ -1378,7 +1378,7 @@ func TestProvision(t *testing.T) {
 			expectedPVSpec: &pvSpec{
 				Name: "test-testi",
 				Capacity: v1.ResourceList{
-					v1.ResourceName(v1.ResourceStorage): bytesToGiQuantity(requestedBytes),
+					v1.ResourceName(v1.ResourceStorage): bytesToQuantity(requestedBytes),
 				},
 				ReclaimPolicy: v1.PersistentVolumeReclaimDelete,
 				CSIPVS: &v1.CSIPersistentVolumeSource{
@@ -1429,7 +1429,7 @@ func TestProvision(t *testing.T) {
 			expectedPVSpec: &pvSpec{
 				Name: "test-testi",
 				Capacity: v1.ResourceList{
-					v1.ResourceName(v1.ResourceStorage): bytesToGiQuantity(requestedBytes),
+					v1.ResourceName(v1.ResourceStorage): bytesToQuantity(requestedBytes),
 				},
 				ReclaimPolicy: v1.PersistentVolumeReclaimDelete,
 				CSIPVS: &v1.CSIPersistentVolumeSource{
@@ -1480,7 +1480,7 @@ func TestProvision(t *testing.T) {
 			expectedPVSpec: &pvSpec{
 				Name: "test-testi",
 				Capacity: v1.ResourceList{
-					v1.ResourceName(v1.ResourceStorage): bytesToGiQuantity(requestedBytes),
+					v1.ResourceName(v1.ResourceStorage): bytesToQuantity(requestedBytes),
 				},
 				ReclaimPolicy: v1.PersistentVolumeReclaimDelete,
 				CSIPVS: &v1.CSIPersistentVolumeSource{
@@ -1522,7 +1522,7 @@ func TestProvision(t *testing.T) {
 			expectedPVSpec: &pvSpec{
 				Name: "test-testi",
 				Capacity: v1.ResourceList{
-					v1.ResourceName(v1.ResourceStorage): bytesToGiQuantity(requestedBytes),
+					v1.ResourceName(v1.ResourceStorage): bytesToQuantity(requestedBytes),
 				},
 				ReclaimPolicy: v1.PersistentVolumeReclaimDelete,
 				VolumeMode:    &volumeModeFileSystem,
@@ -1549,7 +1549,7 @@ func TestProvision(t *testing.T) {
 			expectedPVSpec: &pvSpec{
 				Name: "test-testi",
 				Capacity: v1.ResourceList{
-					v1.ResourceName(v1.ResourceStorage): bytesToGiQuantity(requestedBytes),
+					v1.ResourceName(v1.ResourceStorage): bytesToQuantity(requestedBytes),
 				},
 				ReclaimPolicy: v1.PersistentVolumeReclaimDelete,
 				VolumeMode:    &volumeModeBlock,
@@ -1673,7 +1673,7 @@ func TestProvision(t *testing.T) {
 				AccessModes:   []v1.PersistentVolumeAccessMode{v1.ReadWriteOnce},
 				MountOptions:  []string{"foo=bar", "baz=qux"},
 				Capacity: v1.ResourceList{
-					v1.ResourceName(v1.ResourceStorage): bytesToGiQuantity(requestedBytes),
+					v1.ResourceName(v1.ResourceStorage): bytesToQuantity(requestedBytes),
 				},
 				CSIPVS: &v1.CSIPersistentVolumeSource{
 					Driver:       "test-driver",
@@ -1780,7 +1780,7 @@ func TestProvision(t *testing.T) {
 				Name:          "test-testi",
 				ReclaimPolicy: v1.PersistentVolumeReclaimDelete,
 				Capacity: v1.ResourceList{
-					v1.ResourceName(v1.ResourceStorage): bytesToGiQuantity(requestedBytes),
+					v1.ResourceName(v1.ResourceStorage): bytesToQuantity(requestedBytes),
 				},
 				CSIPVS: &v1.CSIPersistentVolumeSource{
 					Driver:       "test-driver",
@@ -1847,7 +1847,7 @@ func TestProvision(t *testing.T) {
 				Name:          "test-testi",
 				ReclaimPolicy: v1.PersistentVolumeReclaimDelete,
 				Capacity: v1.ResourceList{
-					v1.ResourceName(v1.ResourceStorage): bytesToGiQuantity(requestedBytes),
+					v1.ResourceName(v1.ResourceStorage): bytesToQuantity(requestedBytes),
 				},
 				CSIPVS: &v1.CSIPersistentVolumeSource{
 					Driver:       "test-driver",
@@ -1926,7 +1926,7 @@ func TestProvision(t *testing.T) {
 				Name:          "test-testi",
 				ReclaimPolicy: v1.PersistentVolumeReclaimDelete,
 				Capacity: v1.ResourceList{
-					v1.ResourceName(v1.ResourceStorage): bytesToGiQuantity(requestedBytes),
+					v1.ResourceName(v1.ResourceStorage): bytesToQuantity(requestedBytes),
 				},
 				CSIPVS: &v1.CSIPersistentVolumeSource{
 					Driver:       "test-driver",
@@ -2320,7 +2320,7 @@ func TestProvisionFromSnapshot(t *testing.T) {
 				ReclaimPolicy: v1.PersistentVolumeReclaimDelete,
 				AccessModes:   []v1.PersistentVolumeAccessMode{v1.ReadWriteOnce},
 				Capacity: v1.ResourceList{
-					v1.ResourceName(v1.ResourceStorage): bytesToGiQuantity(requestedBytes),
+					v1.ResourceName(v1.ResourceStorage): bytesToQuantity(requestedBytes),
 				},
 				CSIPVS: &v1.CSIPersistentVolumeSource{
 					Driver:       "test-driver",
@@ -3766,7 +3766,7 @@ func TestProvisionFromPVC(t *testing.T) {
 				ReclaimPolicy: v1.PersistentVolumeReclaimDelete,
 				AccessModes:   []v1.PersistentVolumeAccessMode{v1.ReadWriteOnce},
 				Capacity: v1.ResourceList{
-					v1.ResourceName(v1.ResourceStorage): bytesToGiQuantity(requestedBytes),
+					v1.ResourceName(v1.ResourceStorage): bytesToQuantity(requestedBytes),
 				},
 				CSIPVS: &v1.CSIPersistentVolumeSource{
 					Driver:       "test-driver",