Skip to content

refactor: upstream host override struct#43944

Merged
wbpcode merged 3 commits into
envoyproxy:mainfrom
rudrakhp:strict_stateful_session_status
Mar 27, 2026
Merged

refactor: upstream host override struct#43944
wbpcode merged 3 commits into
envoyproxy:mainfrom
rudrakhp:strict_stateful_session_status

Conversation

@rudrakhp
Copy link
Copy Markdown
Member

@rudrakhp rudrakhp commented Mar 13, 2026

Commit Message: refactor: upstream host override struct
Additional Description: Refactor is required for a subsequent change proposed to add a status to return if strict destination is missing.
Risk Level: Low (internal refactor)
Testing: Unit tests
Docs Changes: No
Release Notes: No
Related #42686

@repokitteh-read-only
Copy link
Copy Markdown

CC @envoyproxy/api-shepherds: Your approval is needed for changes made to (api/envoy/|docs/root/api-docs/).
envoyproxy/api-shepherds assignee is @adisuissa
CC @envoyproxy/api-watchers: FYI only for changes made to (api/envoy/|docs/root/api-docs/).

🐱

Caused by: #43944 was opened by rudrakhp.

see: more, trace.

@rudrakhp rudrakhp force-pushed the strict_stateful_session_status branch 4 times, most recently from 7894d9b to d5a9919 Compare March 13, 2026 12:12
@rudrakhp rudrakhp force-pushed the strict_stateful_session_status branch 3 times, most recently from aaa0098 to 12b45da Compare March 13, 2026 15:26
@paul-r-gall
Copy link
Copy Markdown
Contributor

Please resolve merge conflicts; do not rebase, instead do a merge of the conflicts.

Comment thread api/envoy/extensions/filters/http/stateful_session/v3/stateful_session.proto Outdated
// <envoy_v3_api_field_extensions.filters.http.stateful_session.v3.StatefulSession.strict>` is enabled
// and the requested destination is unavailable.
//
// This allows clients to distinguish between transient failures and errors from upstream.
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.

From a high-level view, it doesn't seem that the feature addresses the description here. Specifically the error-code could be originating from the upstream or from Envoy, and the downstream client will not know what was the cause, no?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

While the status itself wouldn't be enough to determine whether it was due to no available upstream or status from the upstream itself, it would let users configure it to something that is considered safe to retry. For example, it is safe for the downstream client to retry on 425 irrespective of where the status is coming from unlike 503 which might not be safe to retry due to idempotency as pointed out in the issue.

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 this implies that the downstream client knows what the config knob (strict) value is on the proxy, which seems like a broken abstraction that I'm not sure is needed here.

I prefer removing this, and updating the strict description to say that Envoy will return the error code set by this field.

@rudrakhp rudrakhp requested a review from adisuissa March 18, 2026 21:19
@rudrakhp
Copy link
Copy Markdown
Member Author

/retest

//
// This field only takes effect when ``strict`` is set to ``true``. In non-strict mode,
// requests are routed according to the load balancer and this status code is not used.
type.v3.HttpStatus status_on_missing_destination = 4;
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.

Suggested change
type.v3.HttpStatus status_on_missing_destination = 4;
type.v3.HttpStatus status_on_strict_unavailable_destination = 4;

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Will go with status_on_missing_strict_destination in the follow up PR. Didn't want to use the term unavailable as it might be conflated with availability as in non-5XX responses, but we mean the destination not being present for it to connect to.

// <envoy_v3_api_field_extensions.filters.http.stateful_session.v3.StatefulSession.strict>` is enabled
// and the requested destination is unavailable.
//
// This allows clients to distinguish between transient failures and errors from upstream.
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 this implies that the downstream client knows what the config knob (strict) value is on the proxy, which seems like a broken abstraction that I'm not sure is needed here.

I prefer removing this, and updating the strict description to say that Envoy will return the error code set by this field.

Comment thread envoy/upstream/load_balancer.h
@rudrakhp rudrakhp force-pushed the strict_stateful_session_status branch from 713aa72 to e132250 Compare March 24, 2026 17:54
@rudrakhp rudrakhp changed the title feat: ability to set status for missing dest in strict stateful session refactor: upstream host override struct Mar 24, 2026
@rudrakhp rudrakhp force-pushed the strict_stateful_session_status branch from e132250 to ccc35ea Compare March 24, 2026 18:03
@rudrakhp rudrakhp requested a review from adisuissa March 24, 2026 18:03
adisuissa
adisuissa previously approved these changes Mar 24, 2026
Copy link
Copy Markdown
Contributor

@adisuissa adisuissa left a comment

Choose a reason for hiding this comment

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

Overall refactor LGTM.
Assigning @wbpcode for a senior-maintainer review.
/assign @wbpcode

Comment thread source/common/http/filter_manager.h Outdated
Network::Socket::OptionsSharedPtr upstream_options_ =
std::make_shared<Network::Socket::Options>();
std::pair<std::string, bool> upstream_override_host_;
struct UpstreamOverrideHostStorage {
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 wonder whether the "storage" (UpstreamOverrideHostStorage) and "non-storage" (UpstreamOverrideHost) should just be a plain object (just like the storage one), and references to the plain object.
cc @wbpcode who wrote the original code and probably has more context.

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.

I agree with @adisuissa. I can use the UpstreamOverrideHost to store the string and also bool.

And we can update the upstreamOverrideHost() method to return a OptRef rather then current absl::optional<Upstream::LoadBalancerContext::OverrideHost>.

Copy link
Copy Markdown
Member

@wbpcode wbpcode left a comment

Choose a reason for hiding this comment

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

LGTM overall with some minor comments. Thanks for the update.

/wait

Comment thread contrib/golang/filters/http/source/processor_state.h Outdated
Comment thread envoy/upstream/load_balancer.h Outdated
Comment thread source/extensions/clusters/dynamic_modules/abi_impl.cc Outdated
Comment thread source/extensions/load_balancing_policies/dynamic_modules/abi_impl.cc Outdated
@rudrakhp rudrakhp force-pushed the strict_stateful_session_status branch 3 times, most recently from 22d3729 to 57b41de Compare March 26, 2026 15:33
Signed-off-by: Rudrakh Panigrahi <rudrakh97@gmail.com>
Signed-off-by: Rudrakh Panigrahi <rudrakh97@gmail.com>
Signed-off-by: Rudrakh Panigrahi <rudrakh97@gmail.com>
@rudrakhp rudrakhp force-pushed the strict_stateful_session_status branch from 57b41de to 4fb16f9 Compare March 27, 2026 03:04
@rudrakhp
Copy link
Copy Markdown
Member Author

/retest

@rudrakhp rudrakhp requested a review from wbpcode March 27, 2026 06:16
@wbpcode
Copy link
Copy Markdown
Member

wbpcode commented Mar 27, 2026

Please don't use force push once the review started. You could merge main rather than rebase which would be more friendly to reviewer. :)

@wbpcode wbpcode merged commit 9457518 into envoyproxy:main Mar 27, 2026
29 checks passed
TAOXUY pushed a commit to TAOXUY/envoy that referenced this pull request Apr 1, 2026
<!--
!!!ATTENTION!!!

If you are fixing *any* crash or *any* potential security issue, *do
not*
open a pull request in this repo. Please report the issue via emailing
envoy-security@googlegroups.com where the issue will be triaged
appropriately.
Thank you in advance for helping to keep Envoy secure.

!!!ATTENTION!!!

For an explanation of how to fill out the fields, please see the
relevant section
in
[PULL_REQUESTS.md](https://github.com/envoyproxy/envoy/blob/main/PULL_REQUESTS.md)

!!!ATTENTION!!!

Please check the [use of generative AI
policy](https://github.com/envoyproxy/envoy/blob/main/CONTRIBUTING.md?plain=1#L41).

You may use generative AI only if you fully understand the code. You
need to disclose
this usage in the PR description to ensure transparency.
-->

Commit Message: refactor: upstream host override struct
Additional Description: Refactor is required for a subsequent change
proposed to add a status to return if strict destination is missing.
Risk Level: Low (internal refactor)
Testing: Unit tests
Docs Changes: No
Release Notes: No
Related envoyproxy#42686

---------

Signed-off-by: Rudrakh Panigrahi <rudrakh97@gmail.com>
Signed-off-by: Xuyang Tao <taoxuy@google.com>
citrus7 pushed a commit to citrus7/envoy that referenced this pull request Apr 1, 2026
<!--
!!!ATTENTION!!!

If you are fixing *any* crash or *any* potential security issue, *do
not*
open a pull request in this repo. Please report the issue via emailing
envoy-security@googlegroups.com where the issue will be triaged
appropriately.
Thank you in advance for helping to keep Envoy secure.

!!!ATTENTION!!!

For an explanation of how to fill out the fields, please see the
relevant section
in
[PULL_REQUESTS.md](https://github.com/envoyproxy/envoy/blob/main/PULL_REQUESTS.md)

!!!ATTENTION!!!

Please check the [use of generative AI
policy](https://github.com/envoyproxy/envoy/blob/main/CONTRIBUTING.md?plain=1#L41).

You may use generative AI only if you fully understand the code. You
need to disclose
this usage in the PR description to ensure transparency.
-->

Commit Message: refactor: upstream host override struct
Additional Description: Refactor is required for a subsequent change
proposed to add a status to return if strict destination is missing.
Risk Level: Low (internal refactor)
Testing: Unit tests
Docs Changes: No
Release Notes: No
Related envoyproxy#42686

---------

Signed-off-by: Rudrakh Panigrahi <rudrakh97@gmail.com>
Signed-off-by: Jonathan Wu <jtwu@google.com>
nshipilov pushed a commit to nshipilov/envoy that referenced this pull request Apr 13, 2026
<!--
!!!ATTENTION!!!

If you are fixing *any* crash or *any* potential security issue, *do
not*
open a pull request in this repo. Please report the issue via emailing
envoy-security@googlegroups.com where the issue will be triaged
appropriately.
Thank you in advance for helping to keep Envoy secure.

!!!ATTENTION!!!

For an explanation of how to fill out the fields, please see the
relevant section
in
[PULL_REQUESTS.md](https://github.com/envoyproxy/envoy/blob/main/PULL_REQUESTS.md)

!!!ATTENTION!!!

Please check the [use of generative AI
policy](https://github.com/envoyproxy/envoy/blob/main/CONTRIBUTING.md?plain=1#L41).

You may use generative AI only if you fully understand the code. You
need to disclose
this usage in the PR description to ensure transparency.
-->

Commit Message: refactor: upstream host override struct
Additional Description: Refactor is required for a subsequent change
proposed to add a status to return if strict destination is missing.
Risk Level: Low (internal refactor)
Testing: Unit tests
Docs Changes: No
Release Notes: No
Related envoyproxy#42686

---------

Signed-off-by: Rudrakh Panigrahi <rudrakh97@gmail.com>
Signed-off-by: Nick Shipilov <nick.shipilov.n@gmail.com>
krinkinmu pushed a commit to grnmeira/envoy that referenced this pull request Apr 20, 2026
<!--
!!!ATTENTION!!!

If you are fixing *any* crash or *any* potential security issue, *do
not*
open a pull request in this repo. Please report the issue via emailing
envoy-security@googlegroups.com where the issue will be triaged
appropriately.
Thank you in advance for helping to keep Envoy secure.

!!!ATTENTION!!!

For an explanation of how to fill out the fields, please see the
relevant section
in
[PULL_REQUESTS.md](https://github.com/envoyproxy/envoy/blob/main/PULL_REQUESTS.md)

!!!ATTENTION!!!

Please check the [use of generative AI
policy](https://github.com/envoyproxy/envoy/blob/main/CONTRIBUTING.md?plain=1#L41).

You may use generative AI only if you fully understand the code. You
need to disclose
this usage in the PR description to ensure transparency.
-->

Commit Message: refactor: upstream host override struct
Additional Description: Refactor is required for a subsequent change
proposed to add a status to return if strict destination is missing.
Risk Level: Low (internal refactor)
Testing: Unit tests
Docs Changes: No
Release Notes: No
Related envoyproxy#42686

---------

Signed-off-by: Rudrakh Panigrahi <rudrakh97@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants