Skip to content

Conversation

@deepakkinni
Copy link
Collaborator

@deepakkinni deepakkinni commented Dec 3, 2025

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:

  • Modified createBlockVolume in pkg/csi/service/wcp/controller.go to compare volSizeMB with snapshotSizeInMB (both after rounding) instead of comparing raw byte values
  • The validation now enforces strict equality on rounded MB values, which is what CNS actually provisions

Testing 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:

  • TestCreateVolumeFromSnapshotWithDecimalUnits with 4 sub-tests:
    • SameDecimalSize: Create 25G PVC → snapshot → 25G LinkedClone ✅ PASS
    • LargerSize: Create 25G PVC → snapshot → 27G LinkedClone ❌ FAIL (as expected)
    • SmallerSize: Create snapshot → smaller LinkedClone ❌ FAIL (as expected)
    • ExactSnapshotSize: Create snapshot → exact size LinkedClone ✅ PASS

All existing snapshot tests continue to pass:

  • TestWCPCreateDeleteSnapshot ✅ PASS
  • TestCreateVolumeFromSnapshot ✅ PASS

Special notes for your reviewer:

N/A

Release note:

- Change validation to compare rounded MB values instead of raw bytes
- Allows LinkedClone PVCs with decimal units (G) to work correctly
- Add comprehensive unit tests for decimal unit handling
@k8s-ci-robot k8s-ci-robot added the cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. label Dec 3, 2025
@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: deepakkinni

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@k8s-ci-robot k8s-ci-robot added approved Indicates a PR has been approved by an approver from all required OWNERS files. size/L Denotes a PR that changes 100-499 lines, ignoring generated files. labels Dec 3, 2025
@deepakkinni
Copy link
Collaborator Author

Triggering CSI-WCP Pre-checkin Pipeline for this PR... Job takes approximately an hour to complete
Jenkins Build #700

@deepakkinni
Copy link
Collaborator Author

Triggering CSI-TKG Pre-checkin Pipeline for this PR... Job takes approximately an hour to complete
Jenkins Build #645

@deepakkinni
Copy link
Collaborator Author

SUCCESS --- Jenkins Build #645

@deepakkinni
Copy link
Collaborator Author

Triggering CSI-WCP Pre-checkin Pipeline for this PR... Job takes approximately an hour to complete
Jenkins Build #716

@deepakkinni
Copy link
Collaborator Author

SUCCESS --- Jenkins Build #717

@deepakkinni
Copy link
Collaborator Author

Not needed. Size difference is checked in external provisioner

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

approved Indicates a PR has been approved by an approver from all required OWNERS files. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. size/L Denotes a PR that changes 100-499 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants