yunify / qingcloud-csi

Kubernetes volume plugin based on CSI specification which support block storage of qingcloud
Apache License 2.0
36 stars 22 forks source link

[Bug]ControllerExpandVolume does not expanding disk according to stepSize defined in storageClass #200

Closed cumirror closed 2 years ago

cumirror commented 2 years ago

What happened: When the disk is expanded, the capacity is not expanded according to the step size defined by storageClass.

What you expected to happen: ControllerExpandVolume can expand disk correctly.

How to reproduce it (as minimally and precisely as possible):

~# cat csi-high-capacity.yaml
allowVolumeExpansion: true
apiVersion: storage.k8s.io/v1
kind: StorageClass
metadata:
  annotations:
    storageclass.kubernetes.io/is-default-class: "true"
    storageclass.kubesphere.io/supported_access_modes: '["ReadWriteOnce"]'
  name: csi-high-capacity
parameters:
  fsType: ext4
  maxSize: "10000"
  minSize: "20"
  replica: "2"
  stepSize: "10"
  tags: tag-h9ct8qw5
  type: "6"
provisioner: csi-qingcloud
reclaimPolicy: Delete
volumeBindingMode: Immediate

~# cat pvc.yaml
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
  name: test
  namespace: test
spec:
  storageClassName: csi-high-capacity
  accessModes:
  - ReadWriteOnce
  resources:
    requests:
      storage: 30Gi

then edit pvc's storage to 35G

~# kubectl get pvc -n test test -oyaml
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
  annotations:
    kubectl.kubernetes.io/last-applied-configuration: |
      {"apiVersion":"v1","kind":"PersistentVolumeClaim","metadata":{"annotations":{},"name":"test","namespace":"test"},"spec":{"accessModes":["ReadWriteOnce"],"resources":{"requests":{"storage":"35Gi"}},"storageClassName":"csi-high-capacity"}}
    pv.kubernetes.io/bind-completed: "yes"
    pv.kubernetes.io/bound-by-controller: "yes"
    volume.beta.kubernetes.io/storage-provisioner: csi-qingcloud
  creationTimestamp: "2022-04-26T04:24:17Z"
  finalizers:
  - kubernetes.io/pvc-protection
    manager: csi-resizer
    operation: Update
    time: "2022-04-26T04:25:31Z"
  name: test
  namespace: test
  resourceVersion: "44219491"
  uid: 287db31b-7cba-44de-a42e-a9823a7fd074
spec:
  accessModes:
  - ReadWriteOnce
  resources:
    requests:
      storage: 35Gi
  storageClassName: csi-high-capacity
  volumeMode: Filesystem
  volumeName: pvc-287db31b-7cba-44de-a42e-a9823a7fd074
status:
  accessModes:
  - ReadWriteOnce
  capacity:
    storage: 30Gi
  conditions:
  - lastProbeTime: null
    lastTransitionTime: "2022-04-26T04:25:30Z"
    message: Waiting for user to (re-)start a pod to finish file system resize of
      volume on node.
    status: "True"
    type: FileSystemResizePending
  phase: Bound

~# kubectl get pv
NAME                                       CAPACITY   ACCESS MODES   RECLAIM POLICY   STATUS   CLAIM       STORAGECLASS        REASON   AGE
pvc-287db31b-7cba-44de-a42e-a9823a7fd074   100Gi      RWO            Delete           Bound    test/test   csi-high-capacity            9m42s

Anything else we need to know?:

I0426 04:25:19.222752       1 connection.go:183] GRPC request: {"capacity_range":{"required_bytes":37580963840},"volume_id":"vos-7bc33tfw"}
I0426 04:25:30.329457       1 connection.go:185] GRPC response: {"capacity_bytes":107374182400,"node_expansion_required":true}
I0426 04:25:30.330196       1 connection.go:186] GRPC error: <nil>
I0426 04:25:30.422930       1 controller.go:363] Resize volume succeeded for volume "pvc-287db31b-7cba-44de-a42e-a9823a7fd074", start to update PV's capacity
I0426 04:25:30.633996       1 controller.go:369] Update capacity of PV "pvc-287db31b-7cba-44de-a42e-a9823a7fd074" to 100Gi succeeded
I0426 04:25:31.924047       1 controller.go:419] Mark PVC "test/test" as file system resize required

Here storageClass is a code template not the actual sc configuration: https://github.com/yunify/qingcloud-csi/blob/5c98bf2734919f92fb0e20a75f1af1e0f703d280/pkg/disk/rpcserver/controllerserver.go#L674

Environment: