feat(runtime): add ignore-fields selective field reconciliation#256
Open
sapphirew wants to merge 1 commit into
Open
feat(runtime): add ignore-fields selective field reconciliation#256sapphirew wants to merge 1 commit into
sapphirew wants to merge 1 commit into
Conversation
Adds an opt-in, runtime-level mechanism for telling ACK to treat named fields of a custom resource as non-existent: ACK does not send them at create, excludes them from the reconcile delta, does not late-initialize them, and does not persist them to the CR spec. This lets a resource be managed by ACK while specific fields are managed externally (e.g. externally-injected IAM role tags that an SCP forbids ACK from removing). - New annotation services.k8s.aws/ignore-fields (comma-separated JSON-style field paths). - New feature gate SelectiveReconciliation (Alpha, disabled by default). - applyIgnoredFields merges observed values into a deep copy of desired before the delta is computed (suppression + anti-clobber); the stored CR is never mutated. - clearIgnoredFields drops ignored fields at create and from the spec write-back (both patch sides in patchResourceMetadataAndSpec); late-init results are stripped of ignored fields. - FilterIgnoredDeltaDifferences removes ignored-path differences from a computed delta; intended to be called from generated per-resource delta code so requeue/IsSynced paths also ignore drift (see companion code-generator change). - Process-wide SetGlobalFeatureGates/GetGlobalFeatureGates (write-once at startup via BindControllerManager) so generated package-level delta code can consult the gate. - Drift on ignored fields is surfaced via a log line only (no condition in v1). Refs aws-controllers-k8s/community#2367
Contributor
Author
|
Companion code-generator PR: aws-controllers-k8s/code-generator#714 — it adds the call to |
|
[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 |
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.
Summary
This PR adds an opt-in, runtime-level mechanism for selective field reconciliation — telling ACK to treat specific named fields of a custom resource as non-existent. An ignored field is not sent at create, excluded from the reconcile delta, never late-initialized, and never persisted to the CR spec.
The motivating case is aws-controllers-k8s/community#2367: IAM role tags that are injected externally (e.g. by an automated tagging system), where an SCP denies
iam:UntagRole. Today ACK detects the externally-injected tags as drift and tries to remove them, which the SCP rejects, leaving the resource stuck in a reconcile-error loop. With this feature the operator can mark thetagsfield as ignored, so ACK leaves it entirely to the external manager.The feature is opt-in two ways: it only activates when the resource carries the new annotation, and only when the Alpha
SelectiveReconciliationfeature gate is enabled (disabled by default).Semantics
An ignored field is treated as if it does not exist on the desired resource:
patchResourceMetadataAndSpec, so they are never persisted to the stored CR. The stored CR is never mutated in place.ResourceSyncedstaysTruefor ignored-only drift — drift on an ignored field never blocks sync.What's in this PR (runtime pieces)
services.k8s.aws/ignore-fields— comma-separated JSON-style field paths.SelectiveReconciliation(Alpha, disabled by default).applyIgnoredFields— merges observed values into a deep copy of desired before the delta is computed (suppression + anti-clobber); the stored CR is never mutated.clearIgnoredFields— drops ignored fields at create and from the spec write-back (both patch sides inpatchResourceMetadataAndSpec); late-init results are stripped of ignored fields.FilterIgnoredDeltaDifferences— removes ignored-path differences from a computed delta; intended to be called from generated per-resource delta code so requeue /IsSyncedpaths also ignore drift (see companion code-generator change).SetGlobalFeatureGates/GetGlobalFeatureGates— write-once at startup viaBindControllerManager, so generated package-level delta code can consult the gate.Companion PR / ordering
A companion code-generator PR adds a call to
FilterIgnoredDeltaDifferencesin the generated delta template, so that requeue /IsSyncedpaths also ignore drift on ignored fields. That PR depends on this PR being merged and released first, because it imports the new runtime helper. The link will be added here once the code-generator PR exists.Out of scope / follow-ups
generator.yamlallowlist — restricting which fields a given resource is allowed to ignore.Testing
applyIgnoredFields/clearIgnoredFields(and supporting helpers) inpkg/runtime/selective_reconciliation_test.go.go build ./...passes.go test ./pkg/runtime/... ./pkg/condition/... ./pkg/featuregate/... ./apis/...passes.Refs #2367