fix: include PVCs with matching labels regardless of ownerReference#8
Merged
Merged
Conversation
57ab5e9 to
f40f948
Compare
3ec0591 to
227af33
Compare
## Problem
After KubeBlocks upgrade, PVC ownerReference may point to Component instead of
InstanceSet. This causes TreeLoader to skip these PVCs, making the controller
think they do not exist and attempting to recreate them on every reconcile.
This results in:
- Repeated PVC creation attempts in controller logs
- User quota storage being modified unexpectedly
- Potential quota exhaustion errors
## Root Cause
In ReadObjectTree function, the ownership check logic skips objects whose
ownerReference does not point to the root object (InstanceSet):
if len(object.GetOwnerReferences()) > 0 && !model.IsOwnerOf(root, object) {
continue // PVCs owned by Component are skipped here
}
After upgrade, PVC ownerReferences point to Component (new owner hierarchy),
but TreeLoader expects them to point to InstanceSet.
## Solution
Add special handling for PVCs: include them based on matching labels regardless
of ownerReference. PVCs are identified by labels (matching the InstanceSet), so
we can safely include them even if their owner is Component.
This fix:
1. Checks if the object is a PVC
2. If it is a PVC with matching labels, includes it in the tree
3. Prevents duplicate PVC creation attempts
4. Maintains backward compatibility for other resource types
227af33 to
0909671
Compare
- Remove Component kind check - clear any ownerReference regardless of type - Remove needUpdate flag and conditional return logic - Simplify the code to clear ownerReferences whenever they exist Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
zijiren233
approved these changes
Jan 23, 2026
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.
Problem
After KubeBlocks upgrade, PVC ownerReference may point to Component instead of InstanceSet. This causes TreeLoader to skip these PVCs, making the controller think they do not exist and attempting to recreate them on every reconcile.
This results in:
Root Cause
In ReadObjectTree function, the ownership check logic skips objects whose ownerReference does not point to the root object (InstanceSet):
if len(object.GetOwnerReferences()) > 0 && !model.IsOwnerOf(root, object) {
continue // PVCs owned by Component are skipped here
}
After upgrade, PVC ownerReferences point to Component (new owner hierarchy), but TreeLoader expects them to point to InstanceSet.
Solution
Add special handling for PVCs: include them based on matching labels regardless of ownerReference. PVCs are identified by labels (matching the InstanceSet), so we can safely include them even if their owner is Component.
This fix: