Skip to content

fix: include PVCs with matching labels regardless of ownerReference#8

Merged
zijiren233 merged 3 commits into
labring:fix/v0.9.3from
wallyxjh:fix-pvc-ownership-check
Jan 23, 2026
Merged

fix: include PVCs with matching labels regardless of ownerReference#8
zijiren233 merged 3 commits into
labring:fix/v0.9.3from
wallyxjh:fix-pvc-ownership-check

Conversation

@wallyxjh

Copy link
Copy Markdown
Collaborator

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

@wallyxjh wallyxjh force-pushed the fix-pvc-ownership-check branch from 57ab5e9 to f40f948 Compare January 19, 2026 03:41
@wallyxjh wallyxjh force-pushed the fix-pvc-ownership-check branch 2 times, most recently from 3ec0591 to 227af33 Compare January 20, 2026 07:29
@pull-request-size pull-request-size Bot added size/M and removed size/S labels Jan 20, 2026
## 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
@wallyxjh wallyxjh force-pushed the fix-pvc-ownership-check branch from 227af33 to 0909671 Compare January 20, 2026 08:44
wallyxjh and others added 2 commits January 22, 2026 17:54
- 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>
@pull-request-size pull-request-size Bot added size/S and removed size/M labels Jan 23, 2026
@zijiren233 zijiren233 merged commit 3ec4823 into labring:fix/v0.9.3 Jan 23, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants