fix(storages): use the CSI volume handle as NodePublishVolume volume_id - #783
AnshulPatil2005 wants to merge 1 commit into
Conversation
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: The full list of commands accepted by this bot can be found here. DetailsNeeds approval from an approver in each of these files:Approvers can indicate their approval by writing |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #783 +/- ##
=======================================
Coverage 83.08% 83.08%
=======================================
Files 259 259
Lines 22555 22551 -4
=======================================
- Hits 18739 18736 -3
+ Misses 3093 3092 -1
Partials 723 723
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
cd5f153 to
335e3e6
Compare
335e3e6 to
155f070
Compare
Every publish built a volume_id from the PV name plus six random characters against the same target path. The CSI spec makes NodePublishVolume idempotent on (volume_id, target_path), so a volume_id that changes per call defeats it and a driver sees each retry as a new publish. Nothing calls NodeUnpublishVolume, so those mounts are never cleaned up. FUSE drivers such as JuiceFS and Ceph fork a mount helper per publish, so a retried mount stacks bind mounts and leaks helpers. Use Spec.CSI.VolumeHandle, which identifies the volume and is what kubelet sends for the same PV, and reject a PV that has none. The existing idempotency test asserted every field except volume_id; it now covers it and fails without this change. generateRandomString had no other caller and goes with it. Refs openkruise#408 Signed-off-by: Anshul <anshulpatil1022@gmail.com>
155f070 to
a5bd862
Compare
I. Describe what this PR does
Every publish built
volume_idas the PV name plus six random characters, against the same target path:The CSI spec makes
NodePublishVolumeidempotent on(volume_id, target_path), so avolume_idthat changes per call defeats it and the driver sees each retry as a new publish. Nothing in the tree callsNodeUnpublishVolume, so the previous mount is never cleaned up. For FUSE drivers like JuiceFS and Ceph that forks a mount helper per publish, which is the stacking @zhulinwei describes on the issue.Uses
Spec.CSI.VolumeHandleinstead. That identifies the volume rather than the call, and it is what kubelet sends for the same PV, so a driver can recognise a repeat. A PV with no handle is now rejected rather than publishing an emptyvolume_id.generateRandomStringhad no other caller so it goes too.This is only the
volume_idhalf of the issue. The re-mount running outside the guard inEnsureSandboxResumed, and the missing unmount, are separate and I have left them alone.II. Does this pull request fix one issue?
Refs #408
III. Describe how to verify it
go test ./pkg/agent-runtime/storages/ -count=1TestMountProvider_GenerateNodePublishVolumeRequest_Idempotencyalready existed but asserted TargetPath, Readonly, VolumeContext, Secrets and VolumeCapability while skippingvolume_id, which was the only field that was not idempotent. It now checks it and fails on master without this change.IV. Special notes for reviews
Worth a check from someone with a real driver: kubelet passes the volume handle as
volume_id, so this should match what drivers already expect, but the mounts here are issued bysandbox-runtime-storagerather than kubelet and I could only test it against the fakes in tree.TestCreateSymlinkBranchesandTestSystemMountReaderReadMountsWithFixturefail for me on both this branch and a clean master. They look like Windows-only failures in symlink creation and /proc mount parsing, unrelated to this.