Skip to content

fix: handle component deletion when parent cluster is missing#18

Merged
zijiren233 merged 1 commit into
labring:fix/v0.9.3from
wallyxjh:fix-component-deletion-error
Mar 10, 2026
Merged

fix: handle component deletion when parent cluster is missing#18
zijiren233 merged 1 commit into
labring:fix/v0.9.3from
wallyxjh:fix-component-deletion-error

Conversation

@wallyxjh

Copy link
Copy Markdown
Collaborator

When a Cluster is deleted but its owned Components still exist, the Component controller fails to complete the deletion process. The getCluster method returns an error when the parent Cluster is not found, causing the component deletion transformer to enter an infinite requeue loop.

Root Cause

In transformer_component_deletion.go, the getCluster function fetches the parent Cluster to determine the TerminationPolicy for resource cleanup. When the Cluster has already been garbage collected, the Get call returns a NotFound error which is propagated as a generic error, preventing the deletion flow from proceeding.

Solution

Added an apierrors.IsNotFound check in getCluster. When the Cluster is not found, a placeholder Cluster object with a default Delete termination policy is returned, allowing the component deletion to proceed with sub-resource cleanup.

Changes

  • controllers/apps/transformer_component_deletion.go: Handle NotFound error in getCluster by returning a placeholder Cluster with TerminationPolicy: Delete.

Verification

  • Unit test: go test ./controllers/apps/... -run "deletion transformer" -v
  • E2E: Verified orphaned Components are automatically cleaned up after deploying the fix.'

Comment thread controllers/apps/transformer_component_deletion.go Outdated
When the parent Cluster is deleted before Component, the component controller
was returning an error because it couldn't find the cluster. This fix returns
a placeholder cluster with default Delete termination policy when the cluster
is not found, allowing the component deletion to proceed normally.
@wallyxjh wallyxjh force-pushed the fix-component-deletion-error branch from 50df1a2 to 6cb5ade Compare March 10, 2026 08:27
@pull-request-size pull-request-size Bot added size/M and removed size/S labels Mar 10, 2026
@zijiren233 zijiren233 merged commit 48da8b5 into labring:fix/v0.9.3 Mar 10, 2026
3 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