fix: clean up stale BackendTrafficPolicy status when it attaches to no target#9420
Open
vishalsolanki-fs wants to merge 1 commit into
Open
fix: clean up stale BackendTrafficPolicy status when it attaches to no target#9420vishalsolanki-fs wants to merge 1 commit into
vishalsolanki-fs wants to merge 1 commit into
Conversation
…o target A BackendTrafficPolicy that resolves to zero targets left its status stale: - targetRef/targetRefs pointing at a nonexistent object kept the policy in the result set carrying its deep-copied prior status, so Accepted=True persisted with an out-of-date observedGeneration (envoyproxy#8926). - targetSelectors that match no objects never added the policy to the result set, so its status was never reconciled (envoyproxy#8927). Following review feedback, the stale status is cleaned up in the provider status updater rather than by synthesizing a condition in the translator: - The translator stops propagating carried-over stale status for a policy that attached to zero targets this pass (subtractive; no synthesized condition or ancestorRef). Both cases then produce no status for the policy. - The BackendTrafficPolicy status updater handles the resulting status delete by stripping the ancestor conditions owned by this controller from the live object, while preserving ancestors owned by other controllers. If the object itself was deleted, the updater's Get returns NotFound and it is a no-op. Intentionally scoped to BackendTrafficPolicy; the same pattern can be generalized to the sibling policy types in a follow-up. Fixes envoyproxy#8926 Fixes envoyproxy#8927 Signed-off-by: Vishal <[email protected]> Co-authored-by: Cursor <[email protected]>
✅ Deploy Preview for cerulean-figolla-1f9435 ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
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.
What this fixes
A
BackendTrafficPolicythat resolves to zero targets currently keeps a stale status. This addresses two issues with the same symptom but different root causes:targetRef/targetRefspointing at a nonexistent object. The policy stays in the result set carrying its deep-copied prior status, soAccepted=Truepersists with an out-of-dateobservedGeneration.targetSelectorsthat match nothing. The policy never enters the result set, so its status is never reconciled and stays stale.The approach
Per review feedback on #9416, the stale status is cleaned up in the provider status updater rather than by synthesizing a condition in the translator:
ProcessBackendTrafficPolicies): stops propagating carried-over stale status for a policy that attached to zero targets this pass. This is subtractive — no synthesized condition and no inventedancestorRef. Both cases then produce no status for the policy, which the gatewayapi runner turns into a status-store delete.internal/provider/kubernetes/status.go, BackendTrafficPolicy updater): handles the resulting status delete by stripping the ancestor conditions owned by this controller from the live object, while preserving ancestors owned by other controllers. If the object itself was deleted, the status updater'sGetreturnsNotFoundand applying the update is a no-op.Scope & follow-up
This PR is intentionally scoped to
BackendTrafficPolicyto stay focused on the two filed issues. The same two structural gaps exist identically across the sibling policy types (SecurityPolicy,ClientTrafficPolicy,BackendTLSPolicy,EnvoyExtensionPolicy,ExtensionServerPolicy):if update.Delete { return }skip in each status updater (the route path even carries aTODOabout the same dangling-status problem).Both halves here were written to be extractable into shared helpers, so if the maintainers are happy with the approach and cleanup semantics, I'm glad to generalize it across the other policy types in a follow-up PR.
Testing
backendtrafficpolicy-targetref-not-found(BackendTrafficPolicy status does not report missing targetRef and leaves stale observedGeneration #8926)backendtrafficpolicy-targetref-not-found-stale-status(BackendTrafficPolicy status does not report missing targetRef and leaves stale observedGeneration #8926 with a pre-existing on-object stale status)backendtrafficpolicy-selector-no-match(BackendTrafficPolicy status becomes stale when targetSelectors change from matching routes to matching no routes #8927)UpdateHandler.applyagainst a fake client: stale status owned by our controller is cleared, another controller's status is preserved, and a delete for an already-removed object is a no-op.go test ./internal/gatewayapi/... ./internal/provider/kubernetes/...passes;go vetandgofmtare clean. Regenerating goldens changed no existing files.Release note
Added
release-notes/current/bug_fixes/8926-btp-status-target-not-found.md.Made with Cursor
Made with Cursor