Skip to content

disable recreateStream for successful On Demand CDS. - #43163

Merged
wbpcode merged 4 commits into
envoyproxy:mainfrom
paul-r-gall:OnDemandCdsRecreation
Jan 30, 2026
Merged

wbpcode merged 4 commits into
envoyproxy:mainfrom
paul-r-gall:OnDemandCdsRecreation

Conversation

@paul-r-gall

Copy link
Copy Markdown
Contributor

Commit Message: disable recreate stream for successful On Demand CDS.
Additional Description: Before this change, when non-idempotent filters appear before the on-demand filter, they would be triggered twice, potentially causing unwanted behavior. This change make it so that by default, a successful CDS response as triggered by the on demand filter will just cause the filter chain to continue iterating through subsequent filters, rather than restarting the stream.
Risk Level: moderate, this is a behavior change.
Testing: unit, integration.
Docs Changes:
Release Notes: added
AI Usage: Gemini partially generated these changes.

@repokitteh-read-only

Copy link
Copy Markdown

CC @envoyproxy/runtime-guard-changes: FYI only for changes made to (source/common/runtime/runtime_features.cc).

🐱

Caused by: #43163 was opened by paul-r-gall.

see: more, trace.

@adisuissa adisuissa left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Overall LGTM, thanks!
Left a couple of minor comments.

// tests onClusterDiscoveryCompletion when a cluster is available, but recreating a stream failed
TEST_F(OnDemandFilterTest, OnClusterDiscoveryCompletionClusterFoundRecreateStreamFailed) {
TestScopedRuntime scoped_runtime;
scoped_runtime.mergeValues(

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

It is unclear what should be done with these tests once the runtime flag is deprecated. I don't think the tests should disappear, so it makes sense to fix them as part of this PR.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I actually think they should go away, as the dependency on data being present or not will no longer matter after these changes go through.

The test with a "what happens if recreateStream fails" should definitely go away after this flag is removed.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I think it's fine to delete those tests since they depend on recreateStream behavior.

@paul-r-gall

Copy link
Copy Markdown
Contributor Author

/retest

@kyessenov kyessenov self-assigned this Jan 27, 2026
}

// tests onClusterDiscoveryCompletion when a cluster is available
TEST_F(OnDemandFilterTest, OnClusterDiscoveryCompletionClusterFoundNoRecreateStream) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Is this a replacement for OnClusterDiscoveryCompletionClusterFound?
If so, can you add a comment clarifying what to do when deprecating the runtime flag.

@adisuissa

Copy link
Copy Markdown
Contributor

Oh, just saw @kyessenov comment. He is the codeowner, so if he is happy with the modified tests, LGTM.

@kyessenov

Copy link
Copy Markdown
Contributor

/wait

Please duplicate the test so we can remove one when it's time to delete the flag.

@paul-r-gall

Copy link
Copy Markdown
Contributor Author

/retest

kyessenov
kyessenov previously approved these changes Jan 29, 2026
@paul-r-gall

Copy link
Copy Markdown
Contributor Author

/retest

adisuissa
adisuissa previously approved these changes Jan 29, 2026

@adisuissa adisuissa left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

LGTM, thanks!

Signed-off-by: Paul Ogilby <[email protected]>
@paul-r-gall
paul-r-gall dismissed stale reviews from adisuissa and kyessenov via 028fabc January 30, 2026 00:54
@wbpcode wbpcode self-assigned this Jan 30, 2026

@adisuissa adisuissa left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

LGTM, thanks!

@wbpcode wbpcode left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

LGTM. Thanks.

@wbpcode
wbpcode merged commit ade332d into envoyproxy:main Jan 30, 2026
shane-yuan pushed a commit to shane-yuan/envoy that referenced this pull request Feb 11, 2026
Commit Message: disable recreate stream for successful On Demand CDS.
Additional Description: Before this change, when non-idempotent filters
appear before the on-demand filter, they would be triggered twice,
potentially causing unwanted behavior. This change make it so that by
default, a successful CDS response as triggered by the on demand filter
will just cause the filter chain to continue iterating through
subsequent filters, rather than restarting the stream.
Risk Level: moderate, this is a behavior change.
Testing: unit, integration.
Docs Changes: 
Release Notes: added
AI Usage: Gemini partially generated these changes.

---------

Signed-off-by: Paul Ogilby <[email protected]>
grnmeira pushed a commit to grnmeira/envoy that referenced this pull request Mar 20, 2026
Commit Message: disable recreate stream for successful On Demand CDS.
Additional Description: Before this change, when non-idempotent filters
appear before the on-demand filter, they would be triggered twice,
potentially causing unwanted behavior. This change make it so that by
default, a successful CDS response as triggered by the on demand filter
will just cause the filter chain to continue iterating through
subsequent filters, rather than restarting the stream.
Risk Level: moderate, this is a behavior change.
Testing: unit, integration.
Docs Changes:
Release Notes: added
AI Usage: Gemini partially generated these changes.

---------

Signed-off-by: Paul Ogilby <[email protected]>
Signed-off-by: Gustavo <[email protected]>
wdauchy added a commit to wdauchy/envoy that referenced this pull request Sep 3, 2026
Commit Message: disable recreateStream for successful on-demand VHDS.

Additional Description:
This mirrors the on-demand CDS fix in envoyproxy#43163 for the VHDS path. Before this
change, when OnDemandRouteUpdate::onRouteConfigUpdateCompletion resolved a
previously-missing virtual host, recreateStream(nullptr) was invoked, which
(a) re-runs the entire filter chain, double-triggering non-idempotent filters
sitting before the on_demand filter, and (b) reaches
ActiveStream::recreateStream -> Buffer::OwnedImpl::move on the buffered
request body. That buffer can be a sub-iteration zombie when the downstream
stream was reset while VHDS was in flight, producing a remote-reachable crash
(fault at 0x0 inside move) -- the same null-deref signature as the ODCDS crash
fixed by envoyproxy#43163. With this change the VHDS callback continues decoding the
existing stream instead.

To make continueDecoding route to the freshly-discovered virtual host, a new
StreamFilterCallbacks method refreshRouteConfigSnapshot() re-snaps
snapped_route_config_ from the route config provider. Without this re-snap the
resumed router lookup resolves against the pre-VHDS snapshot taken at request
start and 404s. The ODCDS sibling does not need this because cluster lookup
goes through getThreadLocalCluster() per request rather than the per-stream
route snapshot.

The new path is gated by
envoy.reloadable_features.on_demand_vhds_no_recreate_stream (default true),
mirroring envoy.reloadable_features.on_demand_cluster_no_recreate_stream. Set
the guard to false to restore the legacy recreate behavior.

Risk Level: moderate, this is a guarded behavior change.
Testing: unit (on_demand_filter_test), integration (vhds_integration_test).
Docs Changes: n/a
Release Notes: added (changelogs/current/behavior_changes)
Platform Specific Features: n/a

Signed-off-by: William Dauchy <[email protected]>
wdauchy added a commit to wdauchy/envoy that referenced this pull request Sep 3, 2026
Commit Message: disable recreateStream for successful on-demand VHDS.

Additional Description:
This mirrors the on-demand CDS fix in envoyproxy#43163 for the VHDS path. Before this
change, when OnDemandRouteUpdate::onRouteConfigUpdateCompletion resolved a
previously-missing virtual host, recreateStream(nullptr) was invoked, which
(a) re-runs the entire filter chain, double-triggering non-idempotent filters
sitting before the on_demand filter, and (b) reaches
ActiveStream::recreateStream -> Buffer::OwnedImpl::move on the buffered
request body. That buffer can be a sub-iteration zombie when the downstream
stream was reset while VHDS was in flight, producing a remote-reachable crash
(fault at 0x0 inside move) -- the same null-deref signature as the ODCDS crash
fixed by envoyproxy#43163. With this change the VHDS callback continues decoding the
existing stream instead.

To make continueDecoding route to the freshly-discovered virtual host, a new
StreamFilterCallbacks method refreshRouteConfigSnapshot() re-snaps
snapped_route_config_ from the route config provider. Without this re-snap the
resumed router lookup resolves against the pre-VHDS snapshot taken at request
start and 404s. The ODCDS sibling does not need this because cluster lookup
goes through getThreadLocalCluster() per request rather than the per-stream
route snapshot.

The new path is gated by
envoy.reloadable_features.on_demand_vhds_no_recreate_stream (default true),
mirroring envoy.reloadable_features.on_demand_cluster_no_recreate_stream. Set
the guard to false to restore the legacy recreate behavior.

Risk Level: moderate, this is a guarded behavior change.
Testing: unit (on_demand_filter_test), integration (vhds_integration_test).
Docs Changes: n/a
Release Notes: added (changelogs/current/behavior_changes)
Platform Specific Features: n/a

Signed-off-by: William Dauchy <[email protected]>
wdauchy added a commit to wdauchy/envoy that referenced this pull request Sep 4, 2026
Commit Message: disable recreateStream for successful on-demand VHDS.

Additional Description:
This mirrors the on-demand CDS fix in envoyproxy#43163 for the VHDS path. Before this
change, when OnDemandRouteUpdate::onRouteConfigUpdateCompletion resolved a
previously-missing virtual host, recreateStream(nullptr) was invoked, which
(a) re-runs the entire filter chain, double-triggering non-idempotent filters
sitting before the on_demand filter, and (b) reaches
ActiveStream::recreateStream -> Buffer::OwnedImpl::move on the buffered
request body. That buffer can be a sub-iteration zombie when the downstream
stream was reset while VHDS was in flight, producing a remote-reachable crash
(fault at 0x0 inside move) -- the same null-deref signature as the ODCDS crash
fixed by envoyproxy#43163. With this change the VHDS callback continues decoding the
existing stream instead.

To make continueDecoding route to the freshly-discovered virtual host, a new
StreamFilterCallbacks method refreshRouteConfigSnapshot() re-snaps
snapped_route_config_ from the route config provider. Without this re-snap the
resumed router lookup resolves against the pre-VHDS snapshot taken at request
start and 404s. The ODCDS sibling does not need this because cluster lookup
goes through getThreadLocalCluster() per request rather than the per-stream
route snapshot.

The new path is gated by
envoy.reloadable_features.on_demand_vhds_no_recreate_stream (default true),
mirroring envoy.reloadable_features.on_demand_cluster_no_recreate_stream. Set
the guard to false to restore the legacy recreate behavior.

Risk Level: moderate, this is a guarded behavior change.
Testing: unit (on_demand_filter_test), integration (vhds_integration_test).
Docs Changes: n/a
Release Notes: added (changelogs/current/behavior_changes)
Platform Specific Features: n/a

Signed-off-by: William Dauchy <[email protected]>
wdauchy added a commit to wdauchy/envoy that referenced this pull request Sep 4, 2026
Commit Message: disable recreateStream for successful on-demand VHDS.

Additional Description:
This mirrors the on-demand CDS fix in envoyproxy#43163 for the VHDS path. Before this
change, when OnDemandRouteUpdate::onRouteConfigUpdateCompletion resolved a
previously-missing virtual host, recreateStream(nullptr) was invoked, which
(a) re-runs the entire filter chain, double-triggering non-idempotent filters
sitting before the on_demand filter, and (b) reaches
ActiveStream::recreateStream -> Buffer::OwnedImpl::move on the buffered
request body. That buffer can be a sub-iteration zombie when the downstream
stream was reset while VHDS was in flight, producing a remote-reachable crash
(fault at 0x0 inside move), the same null-deref signature as the ODCDS crash
fixed by envoyproxy#43163. With this change the VHDS callback continues decoding the
existing stream instead.

To make continueDecoding route to the freshly-discovered virtual host, a new
StreamFilterCallbacks method refreshRouteConfigSnapshot() re-snaps
snapped_route_config_ from the route config provider. Without this re-snap the
resumed router lookup resolves against the pre-VHDS snapshot taken at request
start and 404s. The ODCDS sibling does not need this because cluster lookup
goes through getThreadLocalCluster() per request rather than the per-stream
route snapshot.

The new path is gated by
envoy.reloadable_features.on_demand_vhds_no_recreate_stream (default true),
mirroring envoy.reloadable_features.on_demand_cluster_no_recreate_stream. Set
the guard to false to restore the legacy recreate behavior.

Risk Level: moderate, this is a guarded behavior change.
Testing: unit (on_demand_filter_test), integration (vhds_integration_test).
Docs Changes: n/a
Release Notes: added (changelogs/current/behavior_changes)
Platform Specific Features: n/a

Signed-off-by: William Dauchy <[email protected]>
wbpcode added a commit that referenced this pull request Oct 5, 2026
Commit Message: disable recreateStream for successful on-demand VHDS.

Additional Description:
This mirrors the on-demand CDS fix in #43163 for the VHDS path. Before
this
change, when OnDemandRouteUpdate::onRouteConfigUpdateCompletion resolved
a
previously-missing virtual host, recreateStream(nullptr) was invoked,
which
re-runs the entire filter chain, so non-idempotent filters sitting
before
the on_demand filter run twice. With this change the VHDS callback
continues decoding the existing stream instead. A crash in
recreateStream()
on this path was also observed in production and is avoided as well.

To make continueDecoding route to the freshly-discovered virtual host, a
new
StreamFilterCallbacks method refreshRouteConfigSnapshot() re-snaps
snapped_route_config_ from the route config provider. Without this
re-snap
the resumed router lookup resolves against the pre-VHDS snapshot taken
at
request start and 404s. The ODCDS sibling does not need this because
cluster
lookup goes through getThreadLocalCluster() per request rather than the
per-stream route snapshot.

The new path is gated by
envoy.reloadable_features.on_demand_vhds_no_recreate_stream (default
true),
mirroring
envoy.reloadable_features.on_demand_cluster_no_recreate_stream.
Set the guard to false to restore the legacy recreate behavior.

Risk Level: moderate, this is a guarded behavior change.
Testing: unit (on_demand_filter_test), integration
(vhds_integration_test).
Docs Changes: n/a
Release Notes: added (changelogs/current/behavior_changes)
Platform Specific Features: n/a

---------

Signed-off-by: William Dauchy <[email protected]>
Signed-off-by: code <[email protected]>
Co-authored-by: code <[email protected]>
mathetake pushed a commit that referenced this pull request Oct 28, 2026
…code paths (#48559)

Commit Message: runtime: remove on_demand_cluster_no_recreate_stream
flag and legacy code paths
Additional Description: 

The guard was added in #43163 (2026-01). This removes it and the legacy
code path, so a completed on-demand cluster discovery always continues
decoding instead of recreating the stream. The guard-disabled unit tests
and the OnDemandClusterDiscoveryWorksWithRecreateStream integration test
are removed, and the explicit overrides are dropped from the remaining
tests.

Risk Level: Low
Testing: unit.
Docs Changes: N/A
Release Notes: Added.
Runtime guard: Removed
envoy.reloadable_features.on_demand_cluster_no_recreate_stream

Signed-off-by: wbpcode <[email protected]>
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