Skip to content

fix(translator): set status for invalid EnvoyPatchPolicy target kind#8788

Open
nishantbkl3345-ship-it wants to merge 4 commits intoenvoyproxy:mainfrom
nishantbkl3345-ship-it:fix-epp-invalid-target-status
Open

fix(translator): set status for invalid EnvoyPatchPolicy target kind#8788
nishantbkl3345-ship-it wants to merge 4 commits intoenvoyproxy:mainfrom
nishantbkl3345-ship-it:fix-epp-invalid-target-status

Conversation

@nishantbkl3345-ship-it
Copy link
Copy Markdown

Summary

This is a small follow-up for #8623 to improve how invalid EnvoyPatchPolicy targetRef cases are handled.

While testing, I noticed that when a policy targets an unsupported kind for the current mode (for example, Gateway in MergeGateways mode), it could be skipped without setting any status. From a user perspective, this makes it hard to understand why the policy isn’t applied.

This change ensures that such cases consistently report:

  • Accepted=False
  • Reason=Invalid

instead of being silently ignored.

What changed

  • Moved target kind validation earlier in the processing flow so it isn’t bypassed by early exits
  • Ensured a status condition is always set for invalid targetRef kinds
  • Updated the merge-gateways invalid-kind testdata to reflect the expected behavior

Validation

Ran the following:

go test ./internal/gatewayapi/...

All tests passed.

Notes

This change does not introduce any new targeting behavior. It only improves visibility by making invalid configurations explicit via status conditions.

Copilot AI review requested due to automatic review settings April 19, 2026 18:34
@nishantbkl3345-ship-it nishantbkl3345-ship-it requested a review from a team as a code owner April 19, 2026 18:34
@netlify
Copy link
Copy Markdown

netlify Bot commented Apr 19, 2026

Deploy Preview for cerulean-figolla-1f9435 ready!

Name Link
🔨 Latest commit 3e4a650
🔍 Latest deploy log https://app.netlify.com/projects/cerulean-figolla-1f9435/deploys/69e5e68564e70d00084993b7
😎 Deploy Preview https://deploy-preview-8788--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.

Signed-off-by: Nishant  <nishantbkl3345@gmail.com>
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Improves user-visible feedback for EnvoyPatchPolicy objects that target an unsupported targetRef.kind for the current translation mode (notably Gateway in MergeGateways mode), ensuring they are marked Accepted=False with Reason=Invalid instead of being silently skipped.

Changes:

  • Move targetRef kind/group validation earlier in ProcessEnvoyPatchPolicies so it can’t be bypassed by early exits.
  • Ensure invalid-target policies are still attached to the appropriate XDS IR entry so their status gets published.
  • Update merge-gateways golden test output to include the expected Accepted=False status condition.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

File Description
internal/gatewayapi/envoypatchpolicy.go Validates unsupported targetRef earlier and ensures invalid policies still surface status via XDS IR attachment.
internal/gatewayapi/testdata/envoypatchpolicy-invalid-target-kind-merge-gateways.out.yaml Updates expected output to include status for invalid target kind in merge-gateways mode.
Comments suppressed due to low confidence (1)

internal/gatewayapi/envoypatchpolicy.go:55

  • The inline comment and the user-facing status message here have awkward/incorrect grammar (e.g. "targeting to a support type" and "... and TargetRef.Kind:%s is supported"). Consider rewording to something like "targetRef must use group %q and kind %q" / "only ... are supported" to improve clarity and correctness (and optionally drop the comma after TargetRef.Kind).
					"TargetRef.Group:%s TargetRef.Kind:%s TargetRef.Namespace:%s TargetRef.Name:%s not found or not accepted (MergeGateways=%t).",
					refGroup, refKind, policy.Namespace, string(refName), t.MergeGateways,
				)
				resolveErr = &status.PolicyResolveError{

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@zirain
Copy link
Copy Markdown
Member

zirain commented Apr 19, 2026

this should be covered by #8475

@nishantbkl3345-ship-it
Copy link
Copy Markdown
Author

Thanks — I took a closer look at #8475 and compared it with the current behavior.

From what I can see, #8475 handles status in several cases, but in the invalid targetRef kind path, the validation still happens after the xdsIR lookup. So if the target doesn’t resolve to an IR entry, the policy can still be skipped before status is attached.

In this PR, I moved the validation earlier and ensured that even in those cases, the policy gets attached to an appropriate IR and Accepted=False is set.

It’s possible I’m misunderstanding part of #8475 though — if this case is already covered there, I’m happy to align or adjust this PR accordingly.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants