Skip to content

on_demand HTTP filter: on-demand CDS response for a second distinct cluster is silently dropped on an already-started subscription #46561

Closed

Description

@xuanmin-zhu

Summary

When the envoy.filters.http.on_demand filter's odcds (on-demand CDS) config is shared across many routes — as it is when odcds is set at the HTTP connection manager (global http_filters) level rather than per-route filter override — the on-demand cluster subscription resolves the first never-before-seen cluster correctly, but every subsequent distinct cluster requested on that same subscription has its CDS response silently dropped. The downstream request that triggered the lookup then times out at the odcds timeout (default/configured, e.g. 5s) and fails with a 503, even though the control plane sent a correct, well-formed response for the requested cluster.

Confirmed present on 1.37.5 (the current latest release).

Root cause (from source)

  • NewGrpcMuxImpl::addWatch() registers the on-demand filter's initial subscription with an empty resource-name set, which the internal WatchMap treats as a wildcard/catch-all watch (wildcard_watches_). This is why the first on-demand cluster lookup on a fresh subscription works — the response is routed to the watch purely by the wildcard fallback, not because the watch's interest was ever updated.
  • Every later on-demand lookup on that same subscription goes through NewGrpcMuxImpl::requestOnDemandUpdate(), which only updates sub_state_ (i.e., what's sent on the wire in the next DeltaDiscoveryRequest) via updateSubscriptionInterest(). It never touches WatchMap's per-watch resource_names_/routing state.
  • When the control plane's response for that second (or Nth) cluster arrives, WatchMap::watchesInterestedIn() has no record that this watch is interested in that resource name, and the watch is no longer a wildcard/catch-all watch either — so the response resource matches no live watch and is dropped without any error being surfaced. The caller is left waiting until the odcds timeout fires.

Relevant source: source/extensions/config_subscription/grpc/new_grpc_mux_impl.{h,cc} (requestOnDemandUpdate, updateWatch, addWatch) and source/extensions/config_subscription/grpc/watch_map.{h,cc} (watchesInterestedIn, updateWatchInterest).

What this blocks

Placing odcds globally on the HTTP connection manager's filter chain (OnDemand.odcds), rather than duplicating it into a PerRouteConfig.odcds override on every individual route, is the natural way to get one shared on-demand CDS subscription instead of one-per-route. That's exactly the configuration this bug breaks: a single global on-demand subscription is, by construction, going to be asked to resolve many different never-before-seen cluster names over its lifetime (one per distinct upstream a route first needs), and only the very first one it's ever asked for will actually work. Every cluster after that silently fails with a request-path 503, indistinguishable at the HTTP layer from an unreachable/misconfigured cluster.

Per-route odcds configuration happens to sidestep this because each route gets its own independent subscription that (in the common case) only ever resolves one cluster — but that means per-route placement pays an N-subscription cost (one on-demand gRPC stream per route) on every listener update/hot reload. When there are nearly 10k routes as in our use case, we observed the performance penalty during hot restart sometimes introduced short but elevated level of 503s to some first-requests waiting to resolve cluster spec from odcds. We'd like to use the global placement (one subscription, shared) without that workaround, to mitigate this perf penalty.

Reproduction

Minimal, self-contained Docker Compose setup: Envoy + a small Go control plane.

Two listeners:

  1. odcds configured per-route on two routes (/a → on-demand cluster on-demand-a, /b → on-demand-b). Both requests succeed (200), since each route has its own subscription.
  2. odcds configured globally on the HTTP connection manager, routes /a → on-demand-x, /b → on-demand-y, no per-route override (one shared subscription). Requesting /a first succeeds (200) — the first cluster, resolved via the wildcard-watch fallback. Requesting /b next times out and returns 503 after the odcds timeout, even though the control plane log shows it sent a correct DeltaDiscoveryResponse containing on-demand-y.

Confirming stats after the failing request:

http.global_on_demand.no_cluster: 1
http.global_on_demand.downstream_rq_5xx: 1
http.global_on_demand.downstream_rq_time: ~5000ms (matches the 5s odcds timeout)

i.e. the response was sent but never resulted in the cluster being added — consistent with the response being dropped at the WatchMap routing step rather than any network/control-plane issue.

Happy to share the full repro (bootstrap config + control plane source + driver script) — kept it out of this report to avoid an unreviewed external link.

Environment

  • Envoy: 1.37.5 (envoyproxy/envoy:v1.37-latest Docker image)
  • Control plane: hand-rolled minimal delta-CDS server (Go, go-control-plane v0.14.0 protos for message types)
  • Reproduced with Docker Compose on macOS (arm64)

Notes

We believe this is the same underlying issue fixed by #46216 ("config: fix a bug where the on demand subscription not works"), which reworks requestOnDemandUpdate/addWatch to also update WatchMap (via a new appendWatchInterest/accept() path) instead of only the wire-level subscription state. Filing this issue to have a citable tracking issue for that fix and to document the specific global-vs-per-route on_demand blast radius, to add more concrete color on the scope of the issue the original PR was trying to solve.

Activity

  1. github-actions commented on Sep 5, 2026

    @github-actions

    This issue has been automatically marked as stale because it has not had activity in the last 30 days. It will be closed in the next 7 days unless it is tagged "help wanted" or "no stalebot" or other activity occurs. Thank you for your contributions.

  2. added
    stale
    on Sep 5, 2026
  3. github-actions commented on Sep 12, 2026

    @github-actions

    This issue has been automatically closed because it has not had activity in the last 37 days. If this issue is still valid, please ping a maintainer and ask them to label it as "help wanted" or "no stalebot". Thank you for your contributions.

  4. added and removed
    stale
    on Sep 27, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions