fix: clean up related resources when primary object is deleted#133
fix: clean up related resources when primary object is deleted#133ifdotpy wants to merge 1 commit intokcp-dev:mainfrom
Conversation
…ev#116) When a primary object is deleted, related resources with origin:kcp are now cleaned up before the primary syncer runs. This ensures finalizers on KCP-side related resources are removed, preventing workspaces from getting stuck in deletion. Changes: - Process related resources before primary deletion in syncer.go - Add forceDelete field to objectSyncer for forced cleanup - Remove early return in handleDeletion that skipped related resources - Pass primaryDeleting flag through related resource processing Fixes kcp-dev#116
|
Adding the "do-not-merge/release-note-label-needed" label because no release-note block was detected, please follow our release note process to remove it. DetailsInstructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository. |
|
[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 |
|
Hi @ifdotpy. Thanks for your PR. I'm waiting for a kcp-dev member to verify that this patch is reasonable to test. If it is, they should reply with Once the patch is verified, the new status will be reflected by the I understand the commands that are listed here. DetailsInstructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository. |
|
Thanks for your pull request. Before we can look at it, you'll need to add a 'DCO signoff' to your commits. 📝 Please follow instructions in the contributing guide to update your commits with the DCO Full details of the Developer Certificate of Origin can be found at developercertificate.org. The list of commits missing DCO signoff:
DetailsInstructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository. I understand the commands that are listed here. |
Summary
Fixes #116 — related resources with
origin: kcpare now cleaned up when the primary object is deleted, preventing orphaned finalizers that block workspace deletion.Problem
When a primary object (e.g.
ChatUIInstance) is deleted:handleDeletion()deletes the local copy and removes the primary finalizerhandleDeletion()returnsrequeue=true, soprocessRelatedResources()is never calledsyncagent.kcp.io/cleanupfinalizer foreverFix
syncer.go: when the primary object has aDeletionTimestamp, callprocessRelatedResources(primaryDeleting=true)before the primary syncer runs. This ensures cleanup happens while the local primary copy still exists (needed for reference resolution).forceDeletefield toobjectSyncer: when set, triggershandleDeletion()even when the source object'sDeletionTimestampis nil. Used fororigin: kcprelated resources during primary deletion.handleDeletion()that skipped related resource processing with the comment "For now we do not delete related resources".destSide.objectafter primary deletion to prevent panics when the local copy has already been removed.Files changed
internal/sync/object_syncer.goforceDeletefield; triggers deletion withoutDeletionTimestamp; removed early returninternal/sync/syncer.gointernal/sync/syncer_related.goprimaryDeletingparameter; setforceDelete=truefororigin: kcpTesting
Tested in our Platform Mesh environment (KCP + Gardener MSP clusters):
ChatUIInstancewith relatedorigin: kcpSecretChatUIInstanceDiscussed the approach with @xrstf in Slack — processing deletions in the opposite order was confirmed as the right approach.