Open jianghushinian opened 2 years ago
I think there might be a little bit of a problem with calculate the part free size, my disk partition looks like this:
$ sudo parted /dev/sdb unit b print free --script -m BYT; /dev/sdb:10737418240B:scsi:512:512:gpt:ATA VBOX HARDDISK:; 1:17408B:1048575B:1031168B:free; 1:1048576B:10485759B:9437184B::test-device:; 2:10485760B:1084227583B:1073741824B:ext4:301d32a8-b9b0-4c60-9585-aa4ee7364e2b:; 3:1084227584B:4305453055B:3221225472B:ext4:f9ee1a0a-e2b9-498f-9d30-97ece3195e81:; 1:4305453056B:7526678527B:3221225472B:free; 5:7526678528B:8600420351B:1073741824B:ext4:ab6a7db4-cc74-4e72-b6aa-f5a09b0ef58b:; 1:8600420352B:10737401343B:2136980992B:free;
In fact, calculate the part free size: 3221225472B = 7526678527B - 4305453056B + 1B.
3221225472B = 7526678527B - 4305453056B + 1B
https://github.com/openebs/device-localpv/blob/cc23b1acdfe9195bc4f412805909deabf46da9b1/pkg/device/device-util.go#L292-L306
Then, in findBestPart the code judgment of if tmp.SizeMiB > partSize ignores the case of equal capacity.
findBestPart
if tmp.SizeMiB > partSize
https://github.com/openebs/device-localpv/blob/cc23b1acdfe9195bc4f412805909deabf46da9b1/pkg/device/device-util.go#L224-L251
These two problems can result in a bug, i cannot apply for another 3Gi PVC:
➜ kubectl get pvc csi-devicepv1-hello1-1 -o yaml apiVersion: v1 kind: PersistentVolumeClaim metadata: creationTimestamp: "2022-07-22T07:18:07Z" finalizers: - kubernetes.io/pvc-protection labels: app: hello1 name: csi-devicepv1-hello1-1 namespace: default resourceVersion: "10121" uid: df90aafe-504d-40b8-bb5d-0c85458a2e68 spec: accessModes: - ReadWriteOnce resources: requests: storage: 3Gi storageClassName: openebs-device-sc volumeMode: Filesystem status: phase: Pending
The PVC will always be in a Pending state.
This pull request is used to fix this bug: https://github.com/openebs/device-localpv/pull/57.
@kmova @iyashu PTAL.
I think there might be a little bit of a problem with calculate the part free size, my disk partition looks like this:
In fact, calculate the part free size:
3221225472B = 7526678527B - 4305453056B + 1B
.https://github.com/openebs/device-localpv/blob/cc23b1acdfe9195bc4f412805909deabf46da9b1/pkg/device/device-util.go#L292-L306
Then, in
findBestPart
the code judgment ofif tmp.SizeMiB > partSize
ignores the case of equal capacity.https://github.com/openebs/device-localpv/blob/cc23b1acdfe9195bc4f412805909deabf46da9b1/pkg/device/device-util.go#L224-L251
These two problems can result in a bug, i cannot apply for another 3Gi PVC:
The PVC will always be in a Pending state.
This pull request is used to fix this bug: https://github.com/openebs/device-localpv/pull/57.