Repository navigation
vhds: fixed bugs where the on demand callbacks may be hung forever - #48000
Conversation
Signed-off-by: wbpcode <[email protected]>
Signed-off-by: wbpcode <[email protected]>
Signed-off-by: wbpcode <[email protected]>
There was a problem hiding this comment.
Copilot review overview
🟡 Changes recommended
Unconditional state resets prevent the runtime guard from fully restoring legacy callback behavior.
Review effort: Balanced
Findings: 1
What changed in this PR
Fixes on-demand VHDS callbacks that could remain unresolved by caching answered aliases and resolving callbacks from published configurations.
Changes:
- Tracks requested and answered VHDS resource IDs.
- Resolves repeated and superseded-update callbacks locally.
- Adds runtime guarding, release notes, and unit coverage.
| File | Description |
|---|---|
envoy/router/route_config_update_receiver.h |
Exposes answered-resource lookup. |
source/common/router/route_config_update_receiver_impl.h |
Stores requested and answered IDs. |
source/common/router/route_config_update_receiver_impl.cc |
Maintains answered-ID state. |
source/common/router/rds_impl.cc |
Resolves dynamic-provider callbacks locally. |
source/common/router/static_route_provider_impl.cc |
Resolves static-provider callbacks locally. |
source/common/router/BUILD |
Adds runtime dependencies. |
source/common/runtime/runtime_features.cc |
Registers the runtime guard. |
test/common/router/vhds_test.cc |
Tests answer-cache lifecycle. |
test/common/router/rds_impl_test.cc |
Tests dynamic-provider behavior. |
test/common/router/static_route_provider_impl_test.cc |
Tests static-provider behavior. |
changelogs/current/bug_fixes/vhds__on_demand_requests_waiting_forever.rst |
Documents the fix and rollback guard. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
|
nice, thanks for the quick fix! |
Resolving queued callbacks against the previous subscription's last update ids on the superseding publish is a pre-existing and rare behavior, and resource_ids_in_last_update_ is slated for removal once the vhds_answered_alias_cache runtime guard is removed. Keep the previous behavior to keep this change small. Signed-off-by: wbpcode <[email protected]>
|
/retest |
|
Thanks for this. One interaction with the on_demand filter after #47183: when VHDS delivers the requested virtual host but none of its routes match the request, onRouteConfigUpdateCompletion() re-runs decodeHeaders(), which requests the same virtual host again. Today the second request is deduplicated and the request waits until the stream idle timeout. With this PR it would be answered locally with host_exists=true, and the filter would request it again. #48079 makes the filter continue to the router (404) when the refreshed route config still has no matching route, which avoids the repeated requests. Would you prefer to handle it here, or in #48079? This is based on reading the code; I have not run #48000 together with the filter. |
wdauchy
left a comment
There was a problem hiding this comment.
Thanks, the approach looks correct to me, including the guard-off path after 1f415b5. Since #46216, a repeat subscribe for an alias the watch already holds is dropped in WatchMap::appendWatchInterest(), so without this PR the second request waits until the stream timeout with any control plane. That would be worth saying in the description and changelog, and an integration test through the real delta mux would cover it (inline). The no-matching-route case is handled in #48079. Inline comments are non-blocking.
| if (!maybe_still_alive.lock()) { | ||
| return; | ||
| } | ||
| const std::string alias = VhdsSubscription::domainNameToAlias( |
There was a problem hiding this comment.
Moving domainNameToAlias(...) into the main-thread lambda also removes a worker-side read of the proto that the main thread replaces on publish. Maybe mention it in the description.
There was a problem hiding this comment.
This isn't a user observable changes. I inclined to avoid the description be more complex.
… route (#48079) Commit Message: on_demand: continue to the router when the on-demand VHDS virtual host has no matching route. Additional Description: After #47183, onRouteConfigUpdateCompletion() re-runs decodeHeaders() once VHDS reports that the virtual host exists. route_exists only means the virtual host exists, not that one of its routes matches the request. If none match, decodeHeaders() requests the same virtual host again. Since #46216 that repeated request is not sent, so the request waits until the stream idle timeout. Before #46216 it was sent and answered again, so the request looped on VHDS. The legacy recreateStream() path has the same problem. This change re-checks route() after refreshing the route config snapshot. route_exists now means a route was found, as the scoped RDS callback already reports. If no route matches, the filter continues to the router, which replies with a 404. Tradeoff: a virtual host that only gains the matching route in a later VHDS update is no longer picked up while the request waits. Upstream never answered this case before: the request looped or waited until the stream idle timeout. Related PRs: - #48000 answers repeated VHDS requests locally. With that change, the decodeHeaders() re-run would get an immediate answer for the same virtual host and request it again. Continuing to the router when no route matches avoids that. - #44401 lets a VHDS virtual host replace an RDS virtual host with the same name. If the VHDS copy also has no route for the request, the request currently waits until the stream idle timeout. With this change it gets a 404. Risk Level: Low. Guarded, limited to on-demand VHDS. Testing: New unit tests in on_demand_filter_test cover both values of the new guard and of on_demand_vhds_no_recreate_stream. New integration tests in vhds_integration_test cover both on_demand_vhds_no_recreate_stream values. Without the fix, the new tests with the guard enabled fail and the integration requests time out waiting for a response. on_demand_filter_test, vhds_integration_test, odcds_integration_test and on_demand_integration_test pass. Docs Changes: N/A Release Notes: Added under changelogs/current/bug_fixes. Platform Specific Features: N/A Runtime guard: envoy.reloadable_features.on_demand_vhds_require_route_match (default true). Set it to false to restore the previous behavior. AI assistance: Cursor helped trace the issue and write the tests. I reviewed and understand all changes. Signed-off-by: William Dauchy <[email protected]>
Signed-off-by: wbpcode <[email protected]>
Signed-off-by: wbpcode <[email protected]>
|
/retest |
1 similar comment
|
/retest |
agrawroh
left a comment
There was a problem hiding this comment.
Looks good! I had some nits but honestly wouldn't push for them
|
|
||
| // A repeated on-demand request for a domain the server has already answered is answered from the | ||
| // published route configuration without another VHDS round trip. | ||
| TEST_F(StaticRouteConfigProviderImplTest, OnDemandRequestForAnsweredAliasIsAnsweredLocally) { |
There was a problem hiding this comment.
Nit: This kinda hand-rolls the setup that StaticVhdsOnDemandTest::setupWithVhds is doing a couple of lines below. Could we move it into the fixture?
| rds_vhost->set_name("vhost_rds1"); | ||
| rds_vhost->add_domains("vhost.rds.first"); | ||
| EXPECT_OK(config_update_info->onRdsUpdate(updated_route_config, "2")); | ||
| EXPECT_TRUE(config_update_info->vhdsResourceIdAnswered("vhost1")); |
There was a problem hiding this comment.
Nit: This only asserts whether the answered flag survives the RDS update but not that the published config still has vhost1.
Signed-off-by: wbpcode <[email protected]>
|
/retest |
1 similar comment
|
/retest |

Commit Message: vhds: fixed bugs where the on demand callbacks may be hung forever
Additional Description:
This fixes two bugs that could leave an on-demand VHDS virtual host request waiting forever, hanging the downstream request until its own timeout.
1: repeated requests for an already answered alias wait for a response that may never come.
When the server answers an on-demand alias — including answering with an empty resource, meaning the virtual host doesn't exist — a later request for the same domain sent a new delta subscribe for the alias and queued a callback waiting for the response. Per the xDS protocol, a server receiving a repeated
resource_names_subscribeentry must re-send the resource even if the client appears subscribed and up to date. In practice the major control planes don't implement this: go-control-plane (and therefore everything built on it, e.g. Envoy Gateway) diffs against the client's acked versions and silently parks the watch, and Istio treats the request as an ACK (its oneAlwaysRespondescape hatch only covers CDS→EDS/LDS→RDS warming). Against such servers the queued callback never resolves.Fix:
RouteConfigUpdateReceivernow tracks every resource id (virtual host name or alias) answered by the current VHDS subscription (vhdsResourceIdAnswered()).requestVirtualHostsUpdate()answers a request for an already answered id locally from the published route configuration, without another round trip. This is safe because the delta subscription to the alias is persistent: if the virtual host appears, changes, or is removed later, the server pushes an update on its own. The answered set is cleared whenever the VHDS subscription is replaced or dropped by an RDS update, since the new subscription carries no guarantee of pushes for previously answered ids.2: callbacks queued against a superseded warming update are never resolved.
Callback resolution on publish only consulted
resourceIdsInLastVhdsUpdate(). If a VHDS update carrying the requested alias was superseded by another update while still warming, the superseded update's resource ids were discarded, so a callback queued against them never resolved even though the eventually published configuration carried its answer.Fix: on each publish, queued callbacks are also resolved against all accumulated answered ids, not just the ids of the update being published.
Both fixes apply to the dynamic (RDS) and static route configuration providers and are guarded by a runtime flag.
Risk Level: Low — the new behavior is limited to the on-demand VHDS path and guarded by a runtime flag.
Testing: unit.
Docs Changes: N/A
Release Notes: added.
Runtime guard: envoy.reloadable_features.vhds_answered_alias_cache (default true; set to false to restore the previous behavior)