Skip to content

fix: clean up stale BackendTrafficPolicy status when it attaches to no target#9420

Open
vishalsolanki-fs wants to merge 1 commit into
envoyproxy:mainfrom
vishalsolanki-fs:fix/btp-status-provider-cleanup
Open

fix: clean up stale BackendTrafficPolicy status when it attaches to no target#9420
vishalsolanki-fs wants to merge 1 commit into
envoyproxy:mainfrom
vishalsolanki-fs:fix/btp-status-provider-cleanup

Conversation

@vishalsolanki-fs

Copy link
Copy Markdown

What this fixes

A BackendTrafficPolicy that resolves to zero targets currently keeps a stale status. This addresses two issues with the same symptom but different root causes:

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:

  • 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 invented ancestorRef. Both cases then produce no status for the policy, which the gatewayapi runner turns into a status-store delete.
  • Provider (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's Get returns NotFound and applying the update is a no-op.

Scope & follow-up

This PR is intentionally scoped to BackendTrafficPolicy to stay focused on the two filed issues. The same two structural gaps exist identically across the sibling policy types (SecurityPolicy, ClientTrafficPolicy, BackendTLSPolicy, EnvoyExtensionPolicy, ExtensionServerPolicy):

  1. the translator's early-return-without-status on a missing/zero target, and
  2. the if update.Delete { return } skip in each status updater (the route path even carries a TODO about 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

Release note

Added release-notes/current/bug_fixes/8926-btp-status-target-not-found.md.

Made with Cursor

Made with Cursor

…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]>
@vishalsolanki-fs vishalsolanki-fs requested a review from a team as a code owner July 5, 2026 17:40
@netlify

netlify Bot commented Jul 5, 2026

Copy link
Copy Markdown

Deploy Preview for cerulean-figolla-1f9435 ready!

Name Link
🔨 Latest commit cf21cfd
🔍 Latest deploy log https://app.netlify.com/projects/cerulean-figolla-1f9435/deploys/6a4a97232a0976000842d412
😎 Deploy Preview https://deploy-preview-9420--cerulean-figolla-1f9435.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

1 participant