Skip to content

fix(policy-k8s): only convert routes in parent namespaces - #15833

Open
es-ma-n wants to merge 1 commit into
linkerd:mainfrom
es-ma-n:policy-skip-untargeted-route-conversion
Open

es-ma-n wants to merge 1 commit into
linkerd:mainfrom
es-ma-n:policy-skip-untargeted-route-conversion

Conversation

@es-ma-n

@es-ma-n es-ma-n commented Dec 2, 2026 •

Copy link
Copy Markdown

Part of #15832

The outbound index sends every route update to every namespace index, so that an index can drop a route whose parents have moved. Each namespace index converts the route before it checks whether any parent is a Service or EgressNetwork in its namespace, so in every other namespace the conversion result is thrown away.

When the conversion fails, for example because of a URLRewrite filter, every namespace index logs "Failed to convert route", and one route update produces one warning per namespace index. Routes attached only to a Gateway of another implementation, such as Istio or Kong, hit this on every update, although the outbound index never serves them.

Check the parents first. If none of them is a Service or EgressNetwork in this namespace, skip the conversion and only run the existing status-based cleanup, which moves into a helper so that both paths share it. Indexes that the route targets are handled as before. The same change applies to HTTP, gRPC, TLS and TCP routes.

In the indexes that the route does not target, the cleanup now also runs when the route fails conversion, because the early return on the error no longer applies there.

Validation:

  • A new unit test creates a Service in each of three namespaces and applies a route that fails conversion. With a Service parent in one of the namespaces, the update logs one warning instead of three. With only a Gateway parent, it logs none instead of three. The test fails on main and passes with this change.
  • The gRPC, TLS and TCP paths get the same change. The test covers only HTTP.
  • cargo test -p linkerd-policy-controller-k8s-index, cargo fmt and cargo clippy --all-targets -- -D warnings pass.
  • On kind (Kubernetes v1.35.0, Gateway API v1.2.1 standard, Linkerd edge-26.11.3 with only the policy controller binary replaced by a build of this branch), using the reproduction from the issue: with 23 namespaces that have a Service, one update of an HTTPRoute that has a URLRewrite filter and only a Gateway parent logged 23 "Failed to convert route" warnings on edge-26.11.3, and 0 with this change. Later, after 10 of those namespaces had been deleted and one had been added, the index held 24 namespace indexes, 14 of them for live namespaces. Patching a route with a Service parent to add a URLRewrite filter then logged 24 warnings on edge-26.11.3, and 1 with this change.

The stale route that a failed conversion leaves in the namespace index that the route targets is fixed separately in #15834. The two changes modify different parts of the same functions and merge cleanly in either order.

The outbound index sends every route update to every namespace index, so
that an index can drop a route whose parents have moved. Each namespace
index converts the route before it checks whether any parent is a
Service or EgressNetwork in its namespace, so in every other namespace
the conversion result is thrown away.

When the conversion fails, for example because of a URLRewrite filter,
every namespace index logs "Failed to convert route", and one route
update produces one warning per namespace index. Routes attached only to
a Gateway of another implementation, such as Istio or Kong, hit this on
every update, although the outbound index never serves them.

Check the parents first. If none of them is a Service or EgressNetwork
in this namespace, skip the conversion and only run the existing
status-based cleanup, which moves into a helper so that both paths share
it. Indexes that the route targets are handled as before. The same
change applies to HTTP, gRPC, TLS and TCP routes.

In the indexes that the route does not target, the cleanup now also runs
when the route fails conversion, because the early return on the error
no longer applies there.

Validation:

- A new unit test creates a Service in each of three namespaces and
  applies a route that fails conversion. With a Service parent in one of
  the namespaces, the update logs one warning instead of three. With
  only a Gateway parent, it logs none instead of three. The test fails
  on main and passes with this change.
- The gRPC, TLS and TCP paths get the same change. The test covers only
  HTTP.
- `cargo test -p linkerd-policy-controller-k8s-index`, `cargo fmt` and
  `cargo clippy --all-targets -- -D warnings` pass.
- On kind (Kubernetes v1.35.0, Gateway API v1.2.1 standard, Linkerd
  edge-26.11.3 with only the policy controller binary replaced by a
  build of this branch), using the reproduction from the issue: with 23
  namespaces that have a Service, one update of an HTTPRoute that has a
  URLRewrite filter and only a Gateway parent logged 23 "Failed to
  convert route" warnings on edge-26.11.3, and 0 with this change.
  Later, after 10 of those namespaces had been deleted and one had been
  added, the index held 24 namespace indexes, 14 of them for live
  namespaces. Patching a route with a Service parent to add a URLRewrite
  filter then logged 24 warnings on edge-26.11.3, and 1 with this
  change.

Part of linkerd#15832

Signed-off-by: Euiseok Jung <euiseok.jung@navercorp.com>
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
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.

1 participant