feat(runtime): Add pre-delete sync step to deleteResource#234
Open
sapphirew wants to merge 4 commits intoaws-controllers-k8s:mainfrom
Open
feat(runtime): Add pre-delete sync step to deleteResource#234sapphirew wants to merge 4 commits intoaws-controllers-k8s:mainfrom
sapphirew wants to merge 4 commits intoaws-controllers-k8s:mainfrom
Conversation
Add AWSResourceDescriptorWithPreDeleteDelta optional interface and preDeleteSync helper method to reconcile spec differences (including compare.is_ignored fields) before calling rm.Delete. This ensures fields like DeletionProtectionEnabled are synced to AWS before deletion. The pre-delete sync: - Uses DeltaForPreDelete if the descriptor implements the optional interface, otherwise falls back to standard Delta - Calls rm.Update when spec differences are detected - Proceeds with deletion even if the update fails - Is a no-op when no spec differences exist
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: sapphirew 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 |
…emented When the resource descriptor does not implement the optional AWSResourceDescriptorWithPreDeleteDelta interface, preDeleteSync now returns immediately instead of falling back to the standard Delta. The standard Delta can detect spec differences that are expected during normal operation (e.g. tags added by EnsureTags during Sync). Calling rm.Update with those differences during deletion could cause unintended side effects like stripping tags from the AWS resource. Since the standard Delta already excludes compare.is_ignored fields, there is nothing extra to reconcile before deletion without the pre-delete variant.
Add five unit tests to reconciler_test.go covering pre-delete sync behavior during resource deletion: - ReadOne returns NotFound: finalizer removed, no Update or Delete - ReadOne returns non-NotFound error: error propagated, no Update or Delete - Descriptor implements DeltaForPreDelete: pre-delete delta method used - Descriptor does not implement DeltaForPreDelete: no-op, deletion proceeds - DeletionProtection scenario: Update disables protection, then Delete called Includes preDeleteDescriptorMock type and helper functions for test setup.
Author
|
/test ec2-controller-test |
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.
Add
AWSResourceDescriptorWithPreDeleteDeltaoptional interface and preDeleteSync helper method to reconcile spec differences (includingcompare.is_ignoredfields) before calling rm.Delete. This ensures fields likeDeletionProtectionEnabledare synced to AWS before deletion.The pre-delete sync:
DeltaForPreDeleteif the descriptor implements the optional interface, otherwise falls back to standard Deltarm.Updatewhen spec differences are detectedIssue #, if available:
Description of changes:
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.