fix: clear PV ClaimRef on release and fix VolumeName translation - #4035
Open
jainbhavya65 wants to merge 2 commits into
Open
fix: clear PV ClaimRef on release and fix VolumeName translation#4035jainbhavya65 wants to merge 2 commits into
jainbhavya65 wants to merge 2 commits into
Conversation
- Use mappings.VirtualToHostName instead of HostNameCluster for VolumeName to prevent double-wrapping of dynamic PV names - Clear ClaimRef on Released host PVs when PVC is deleted and reclaimPolicy is Retain - Add nil-safety guards in translateUpdateBackwards
jainbhavya65
force-pushed
the
fix/pv-claimref-lifecycle
branch
from
June 25, 2026 16:53
7842ed8 to
daadb3a
Compare
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes using high effort and found 1 potential issue.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit daadb3a. Configure here.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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 issue type does this pull request address? (keep at least one, remove the others)
kind bug
kind fix
What does this pull request do? Which issues does it resolve? (use resolves #<issue_number> if possible)
Fixes PV ClaimRef being incorrectly cleared when PVC is deleted with Retain policy.
Fixes PV stuck in Released phase after admin clears ClaimRef.
Fixes host PV deletion not propagating to virtual PV.
Fixes VolumeName double-wrapping for dynamically provisioned PVs.
Please provide a short message that should be published in the vcluster release notes
Fixed PersistentVolume lifecycle sync: ClaimRef now preserved on Released PVs matching standard Kubernetes behavior, admin-cleared ClaimRef correctly propagates to host allowing PV reuse, host PV deletion cleans up virtual PV, and VolumeName translation no longer double-wraps dynamic PV names.
What else do we need to know?
Changes in pkg/controllers/resources/persistentvolumes/:
SyncToHost: host-originated PVs no longer incorrectly deleted; ClaimRef clearing on virtual PV propagates to host
Sync + SyncToVirtual: host PV deletion now deletes virtual PV
shouldSync: Available PVs with existing virtual PV continue syncing instead of being deleted
translate.go: nil-safety guards for ClaimRef access during PVC deletion transitions
Changes in pkg/controllers/resources/persistentvolumeclaims/:
translate.go: VolumeName uses PV mapper (mappings.VirtualToHostName) to prevent double-wrapping
E2E Tests
Default Test Execution
The mandatory PR suite runs automatically. Only specify additional test suites below if needed.
Additional test suites
Additional test suite(s) that will be executed before the mandatory PR suite:
Note
Medium Risk
Changes core PV/PVC sync paths that affect reclaim, binding, and deletion propagation between host and virtual clusters.
Overview
Fixes PersistentVolume and PVC sync behavior around Retain reclaim, ClaimRef clearing, host deletion, and VolumeName mapping.
PV syncer no longer treats host-originated PVs (annotated with
HostClusterPersistentVolumeAnnotation) as delete-on-sync; clearing ClaimRef on the virtual PV now propagates to a Released host PV so both can move to Available. Host PV deletion triggers virtual PV deletion in Sync and SyncToVirtual. shouldSync keeps syncing host PVs that have no ClaimRef when a matching virtual PV still exists (status updates). translateUpdateBackwards allows copying a cleared ClaimRef from the host while still blocking new claim refs when the host PV is Available.PVC translate replaces blind
HostNameClusteron VolumeName with logic that uses the host PV name from the annotation when the PV was synced from the host, leaves the name unchanged if a host PV with that name already exists, and only translates otherwise—avoiding double-wrapping of dynamic PV names.Adds a Retain reclaim e2e case (PVC delete → PV Available on vCluster and host) and wires WithContext(ctx) on existing Eventually polls; adds a PVC syncer unit test for VolumeName when PV sync is enabled.
Reviewed by Cursor Bugbot for commit 8b1dfaf. Bugbot is set up for automated code reviews on this repo. Configure here.