Skip to content

Commit

Permalink
Merge pull request #1861 from travisyx/automated-cherry-pick-of-#1826-#…
Browse files Browse the repository at this point in the history
…1836-#1838-#1841-upstream-release-1.15

Automated cherry pick of #1826: Add ControllerModifyVolume E2E tests
#1836: Create documentation for ControllerModifyVolume and controller default
#1838: Enable VolumeAttributesClass feature gate for CI runs
#1841: Update logic to use SI for VACs
  • Loading branch information
k8s-ci-robot authored Nov 5, 2024
2 parents b038bcb + 547bc8b commit caa3eae
Show file tree
Hide file tree
Showing 16 changed files with 331 additions and 151 deletions.
2 changes: 2 additions & 0 deletions deploy/kubernetes/base/controller/controller.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,8 @@ spec:
args:
- "--v=5"
- "--endpoint=unix:/csi/csi.sock"
- "--supports-dynamic-iops-provisioning=hyperdisk-balanced,hyperdisk-extreme"
- "--supports-dynamic-throughput-provisioning=hyperdisk-balanced,hyperdisk-throughput,hyperdisk-ml"
env:
- name: GOOGLE_APPLICATION_CREDENTIALS
value: "/etc/cloud-sa/cloud-sa.json"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,39 +7,39 @@ metadata:
name: imagetag-csi-provisioner-prow-rc
imageTag:
name: registry.k8s.io/sig-storage/csi-provisioner
newTag: "v3.4.0"
newTag: "v5.1.0"
---
apiVersion: builtin
kind: ImageTagTransformer
metadata:
name: imagetag-csi-attacher-prow-rc
imageTag:
name: registry.k8s.io/sig-storage/csi-attacher
newTag: "v4.2.0"
newTag: "v4.4.3"
---
apiVersion: builtin
kind: ImageTagTransformer
metadata:
name: imagetag-csi-resize-prow-rc
imageTag:
name: registry.k8s.io/sig-storage/csi-resizer
newTag: "v1.7.0"
newTag: "v1.11.1"
---
apiVersion: builtin
kind: ImageTagTransformer
metadata:
name: imagetag-csi-snapshotter-prow-head
imageTag:
name: registry.k8s.io/sig-storage/csi-snapshotter
newTag: "v6.1.0"
newTag: "v6.3.3"
---
apiVersion: builtin
kind: ImageTagTransformer
metadata:
name: imagetag-csi-node-registrar-prow-rc
imageTag:
name: registry.k8s.io/sig-storage/csi-node-driver-registrar
newTag: "v2.7.0"
newTag: "v2.9.3"
---
apiVersion: builtin
kind: ImageTagTransformer
Expand All @@ -48,6 +48,6 @@ metadata:
imageTag:
name: registry.k8s.io/cloud-provider-gcp/gcp-compute-persistent-disk-csi-driver
newName: gcr.io/k8s-staging-cloud-provider-gcp/gcp-compute-persistent-disk-csi-driver
newTag: "v1.14.2-rc1"
newTag: "v1.15.0-rc1"
---

7 changes: 0 additions & 7 deletions deploy/kubernetes/overlays/dev/driver-args.yaml

This file was deleted.

8 changes: 0 additions & 8 deletions deploy/kubernetes/overlays/dev/kustomization.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,6 @@ resources:
# Here dev overlay is using the same image as alpha
transformers:
- ../../images/stable-master
# Apply patches to support dynamic provisioning for hyperdisks
patches:
- path: ./driver-args.yaml
target:
group: apps
version: v1
kind: Deployment
name: csi-gce-pd-controller
# To change the dev image, add something like the following.
#images:
#- name: gke.gcr.io/gcp-compute-persistent-disk-csi-driver
Expand Down
41 changes: 41 additions & 0 deletions docs/kubernetes/user-guides/volume-attributes-class.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
# VolumeAttributesClass User Guide

>**Attention:** VolumeAttributesClass is a Kubernetes Beta feature since v1.31, but was initially introduced as an alpha feature in v1.29. See [this blog post](https://kubernetes.io/docs/concepts/storage/volume-attributes-classes/) for more information on VolumeAttributesClasses and how to enable the feature gate.
### VolumeAttributesClass Example

This example provisions a hyperdisk-balanced and then updates its IOPS and throughput.

1. Create the VolumeAttributesClasses (VACs), PVC, Storage Classes, and Pod
```
$ kubectl apply -f ./examples/kubernetes/demo-vol-create.yaml
```

This creates the VACs silver and gold, with the VAC for silver being the initial metadata for the PV and gold representing the update. This file also create a storage class test-sc. Note that the IOPS/throughput takes priority from the VACs if they are different. Then, a PVC is created, specifying the storage class for the PV being test-sc and the VAC being silver. Finally, a pod is created with the volume being created from the PVC we defined.

2. Verify the PV is properly created
```
$ kubectl get pvc
NAME STATUS VOLUME CAPACITY ACCESS MODES STORAGECLASS VOLUMEATTRIBUTESCLASS AGE
test-pvc Bound {pv-name} 64Gi RWO test-sc silver {some-time}
```

3. Update the IOPS/throughput for the created PV
```
$ kubectl apply -f ./examples/kubernetes/demo-vol-update.yaml
```

4. Verify the PV VAC is properly updated
```
$ kubectl get pvc
NAME STATUS VOLUME CAPACITY ACCESS MODES STORAGECLASS VOLUMEATTRIBUTESCLASS AGE
test-pvc Bound {pv-name} 64Gi RWO test-sc gold {some-time}
```

After verifying the VAC is updated from the PV, we can check that the IOPS and throughput are properly updated.

```
$ gcloud compute disks describe {pv-name} --zone={pv-zone}
```

Ensure that the provisionedIops and provisionedThroughput fields match those from the gold VAC. Note that it will take a few minutes for the value updates to be reflected
59 changes: 59 additions & 0 deletions examples/kubernetes/demo-vol-create.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
apiVersion: storage.k8s.io/v1
kind: StorageClass
metadata:
name: test-sc
provisioner: pd.csi.storage.gke.io
parameters:
type: "hyperdisk-balanced"
provisioned-iops-on-create: "3000"
provisioned-throughput-on-create: "150Mi"
volumeBindingMode: WaitForFirstConsumer
---
apiVersion: storage.k8s.io/v1beta1
kind: VolumeAttributesClass
metadata:
name: silver
driverName: pd.csi.storage.gke.io
parameters:
iops: "3000"
throughput: "150Mi"
---
apiVersion: storage.k8s.io/v1beta1
kind: VolumeAttributesClass
metadata:
name: gold
driverName: pd.csi.storage.gke.io
parameters:
iops: "3013"
throughput: "151Mi"
---
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: test-pvc
spec:
storageClassName: test-sc
volumeAttributesClassName: silver
accessModes:
- ReadWriteOnce
resources:
requests:
storage: 64Gi
---
apiVersion: v1
kind: Pod
metadata:
name: nginx
spec:
volumes:
- name: vol
persistentVolumeClaim:
claimName: test-pvc
containers:
- name: nginx
image: nginx:1.14.2
ports:
- containerPort: 80
volumeMounts:
- mountPath: "/vol"
name: vol
12 changes: 12 additions & 0 deletions examples/kubernetes/demo-vol-update.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: test-pvc
spec:
storageClassName: test-sc
volumeAttributesClassName: gold
accessModes:
- ReadWriteOnce
resources:
requests:
storage: 64Gi
99 changes: 0 additions & 99 deletions examples/kubernetes/demo-vol-update.yml

This file was deleted.

2 changes: 1 addition & 1 deletion pkg/common/parameters.go
Original file line number Diff line number Diff line change
Expand Up @@ -343,7 +343,7 @@ func ExtractModifyVolumeParameters(parameters map[string]string) (ModifyVolumePa
}
modifyVolumeParams.IOPS = &iops
case "throughput":
throughput, err := ConvertStringToInt64(value)
throughput, err := ConvertMiStringToInt64(value)
if err != nil {
return ModifyVolumeParameters{}, fmt.Errorf("parameters contain invalid throughput parameter: %w", err)
}
Expand Down
2 changes: 1 addition & 1 deletion pkg/common/parameters_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -485,7 +485,7 @@ func TestSnapshotParameters(t *testing.T) {
func TestExtractModifyVolumeParameters(t *testing.T) {
parameters := map[string]string{
"iops": "1000",
"throughput": "500",
"throughput": "500Mi",
}

iops := int64(1000)
Expand Down
14 changes: 7 additions & 7 deletions pkg/gce-pd-csi-driver/controller_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1789,7 +1789,7 @@ func TestCreateVolumeWithVolumeAttributeClassParameters(t *testing.T) {
},
},
},
MutableParameters: map[string]string{"iops": "20000", "throughput": "600"},
MutableParameters: map[string]string{"iops": "20000", "throughput": "600Mi"},
},
expIops: 20000,
expThroughput: 600,
Expand Down Expand Up @@ -1822,7 +1822,7 @@ func TestCreateVolumeWithVolumeAttributeClassParameters(t *testing.T) {
},
},
},
MutableParameters: map[string]string{"iops": "20000", "throughput": "600"},
MutableParameters: map[string]string{"iops": "20000", "throughput": "600Mi"},
},
expIops: 0,
expThroughput: 0,
Expand Down Expand Up @@ -1890,7 +1890,7 @@ func TestVolumeModifyOperation(t *testing.T) {
name: "Update volume with valid parameters",
req: &csi.ControllerModifyVolumeRequest{
VolumeId: testVolumeID,
MutableParameters: map[string]string{"iops": "20000", "throughput": "600"},
MutableParameters: map[string]string{"iops": "20000", "throughput": "600Mi"},
},
diskType: "hyperdisk-balanced",
params: &common.DiskParameters{
Expand All @@ -1906,7 +1906,7 @@ func TestVolumeModifyOperation(t *testing.T) {
name: "Update volume with invalid parameters",
req: &csi.ControllerModifyVolumeRequest{
VolumeId: testVolumeID,
MutableParameters: map[string]string{"iops": "0", "throughput": "0"},
MutableParameters: map[string]string{"iops": "0", "throughput": "0Mi"},
},
diskType: "hyperdisk-balanced",
params: &common.DiskParameters{
Expand All @@ -1922,7 +1922,7 @@ func TestVolumeModifyOperation(t *testing.T) {
name: "Update volume with valid parameters but invalid disk type",
req: &csi.ControllerModifyVolumeRequest{
VolumeId: testVolumeID,
MutableParameters: map[string]string{"iops": "20000", "throughput": "600"},
MutableParameters: map[string]string{"iops": "20000", "throughput": "600Mi"},
},
diskType: "pd-ssd",
params: &common.DiskParameters{
Expand Down Expand Up @@ -2053,7 +2053,7 @@ func TestVolumeModifyErrorHandling(t *testing.T) {
},
},
modifyReq: &csi.ControllerModifyVolumeRequest{
MutableParameters: map[string]string{"iops": "3001", "throughput": "151"},
MutableParameters: map[string]string{"iops": "3001", "throughput": "151Mi"},
},
modifyVolumeErrors: map[*meta.Key]error{
meta.ZonalKey(name, "us-central1-a"): &googleapi.Error{
Expand Down Expand Up @@ -2089,7 +2089,7 @@ func TestVolumeModifyErrorHandling(t *testing.T) {
},
},
modifyReq: &csi.ControllerModifyVolumeRequest{
MutableParameters: map[string]string{"iops": "10000", "throughput": "2400"},
MutableParameters: map[string]string{"iops": "10000", "throughput": "2400Mi"},
},
modifyVolumeErrors: map[*meta.Key]error{
meta.ZonalKey(name, "us-central1-a"): &googleapi.Error{Code: int(codes.InvalidArgument), Message: "InvalidArgument"},
Expand Down
Loading

0 comments on commit caa3eae

Please sign in to comment.