Fix size validation for volumes from snapshots with decimal units #3780
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
What this PR does / why we need it:
Fixes a bug where creating a LinkedClone PVC from a VolumeSnapshot fails when using decimal storage units (G) instead of binary units (Gi).
The issue occurred because the size validation was comparing raw byte values instead of the rounded MB values that CNS actually uses for provisioning. When a user creates a PVC with 25G (25,000,000,000 bytes), the CSI driver rounds this to 23,842 MB for CNS provisioning. However, the old validation compared the raw byte value (25,000,000,000) against the snapshot size in bytes (23,842 MB * 1,048,576), causing a mismatch and rejecting the restore.
This fix changes the validation to compare the rounded MB values instead, ensuring that LinkedClone PVCs created with the same decimal size specification as the source PVC will succeed.
Changes:
createBlockVolumeinpkg/csi/service/wcp/controller.goto comparevolSizeMBwithsnapshotSizeInMB(both after rounding) instead of comparing raw byte valuesTesting done:
Pre-checkins:
PASS WCP https://jenkins-vcf-csifvt.devops.broadcom.net/job/wcp-instapp-e2e-pre-checkin/700/
PASS VKS https://jenkins-vcf-csifvt.devops.broadcom.net/job/vks-instapp-e2e-pre-checkin/645/
Added comprehensive unit tests in
pkg/csi/service/wcp/controller_test.go:TestCreateVolumeFromSnapshotWithDecimalUnitswith 4 sub-tests:All existing snapshot tests continue to pass:
TestWCPCreateDeleteSnapshot✅ PASSTestCreateVolumeFromSnapshot✅ PASSSpecial notes for your reviewer:
N/A
Release note: