Repository navigation
Introduce istio.hashable_string filter state factory - #6905
Merged
istio-testing merged 1 commit intoMar 16, 2026
Merged
Conversation
This is part of the fix for istio/istio#58630 and you can find some additional context in that ticket (the other part will be to the pilot, and we'd also like to backport this change to 1.29 release branch as well). To understand why this change is needed we have to start with some background. In ambient multicluster, specifically in multi-network deployments, we rely on ambient E/W gateway to transfer data from one network to another. When communicating across network boundaries in ambient we use double-HBONE (HBONE inside another HBONE). The E/W gateway terminate the outer HBONE tunnel and transfers the inner HBONE tunnel untouched to the destination. Envoy configuration of ambient E/W gateway has two listeners important for understanding this change - `connect_terminate` and `main_internal`. `connect_terminate` listener is responsible for terminating outer HBONE tunnel, extracting and preserving all the relevant routing information (e.g. authority from HTTP CONNECT request and some headers). However, `connect_terminate` does not make any routing decisions, instead it passes all the relevant information to the internal `main_internal` listener via filter state, and then `main_internal` listener is actually responsible for routing the request correctly. To transfer data to `main_internal` listener, `connect_terminate` listener opens an "internal" connection - it's a connection implemented purely in Envoy, but it implements the same interface as any other connections that Envoy supports and for many intents and purposes is not that different from say TCP connections. One thing that is particularly important for this PR is that Envoy does connection pooling for internal connections like it does for any other connections. Connections from the same pool assumed to share the same filter state (via transport socket options) with the upstream internal listener (e.g., `main_internal` listener in our case). So if you have two HTTP2 streams with different authority in the HBONE connect requests, only authority from the stream handled first will be communicated to the upstream internal listener - that's not what we want. Envoy in principle recognizes that filter state may affect some routing decisions, so for some types of filter state objects shared with upstream Envoy can tell that it should use different connection pools to avoid mixing unrelated requests together, however `envoy.string` type we currently use to communicate authority from the HBONE CONNECT requests is not one of such types. Recently, Envoy introduced `envoy.hashable_string` that does what we need (see envoyproxy/envoy#43208), but this change didn't make it to Envoy 1.37 release branch and it will not be backported. NOTE: I checked other existing filter state object types, and they don't suit us either, so upstream Envoy `envoy.hashable_string` is basically the first and the only one that works for us. NOTE: From Envoy point of view that change is not a bug or security fix, so the fact that it should not be backported makes perfect sense, but just in case I also explicitly asked in that PR if we could backport it and got an explicit response that it's quite undesirable. So this PR introduces `istio.hashable_string` which does exactly the same thing that upstream `envoy.hashable_string` does, however we can backport it to the Istio's 1.29 release branch without relying on upstream Envoy. Eventually, we can phase it out in favor of the upstream Envoy `envoy.hashable_string`. With the current Istio release cadence, according to https://istio.io/latest/docs/releases/supported-releases/, we should be able to phase it out completely in about 2 quarters and 6 weeks. Together with the fact that the extensions is quite small, I think that it's manageable to add it to the Istio proxy repor, even if it's not ideal. Signed-off-by: Mikhail Krinkin <[email protected]>
Contributor
|
/retest |
keithmattix
approved these changes
Mar 16, 2026
Collaborator
|
In response to a cherrypick label: new pull request created: #6906 |
krinkinmu
added a commit
to krinkinmu/istio
that referenced
this pull request
Mar 18, 2026
…red with upstream This is the second part of the fix for istio#58630 (the first part was a change to the proxy to add support for istio.hashable_string in istio/proxy#6905). The brief summary of the problem is that multiple requests in Envoy can be multiplexed over the same connection pool, even when connecting to internal listeners. Envoy makes a decision on whether requests can be multiplexed together using various inputs, but when it decides to multiplex multiple requests together and use the same connection pool for those, it will share exactly the same filter state with the upstream, even if requests produced different filter state values. That happens because not all filter state value types are considered when Envoy makes the decision whether it should multiplex multiple requests together or not. In particular, Envoy does not consider filter states with type `envoy.string` when it decides to multiplex the requests. So currently if two requests have different authority in HBONE CONNECT request, they still can be multiplexed over the same connection pool in Envoy and only one of the authorites will actually be shared with the internal listener - that's not correct. For all filter state values that we share with upstream, going forward, we should use `istio.hashable_string` instead of `envoy.string`, because `istio.hashable_string` is actually considered by Envoy when it makes the decision to multiplex. `istio.hashable_string` is equivalent to `envoy.hashable_string`, but `envoy.hashable_string` was introduced recently and is not available in all Envoy versions we need (and it will not be backported). So for the time being we will use our custom implementation and in a few quarters, once older versions of Istio fall off the support window, we can migrate everything to Envoy native `envoy.hashable_string`. The issue has not been caught by any of our tests, so this PR also modfies the ambient multicluster tests to catch this particular issue. From what I know it does not currently affect single-cluster deployments and waypoints (see istio#58630 (comment)), so it appears to be reasonable to just modify the multicluster tests. Fixes istio#58630 Signed-off-by: Mikhail Krinkin <[email protected]>
istio-testing
pushed a commit
to istio/istio
that referenced
this pull request
Mar 18, 2026
…red with upstream (#59513) * Switch to newly introduced istio.hashable_string for filter state shared with upstream This is the second part of the fix for #58630 (the first part was a change to the proxy to add support for istio.hashable_string in istio/proxy#6905). The brief summary of the problem is that multiple requests in Envoy can be multiplexed over the same connection pool, even when connecting to internal listeners. Envoy makes a decision on whether requests can be multiplexed together using various inputs, but when it decides to multiplex multiple requests together and use the same connection pool for those, it will share exactly the same filter state with the upstream, even if requests produced different filter state values. That happens because not all filter state value types are considered when Envoy makes the decision whether it should multiplex multiple requests together or not. In particular, Envoy does not consider filter states with type `envoy.string` when it decides to multiplex the requests. So currently if two requests have different authority in HBONE CONNECT request, they still can be multiplexed over the same connection pool in Envoy and only one of the authorites will actually be shared with the internal listener - that's not correct. For all filter state values that we share with upstream, going forward, we should use `istio.hashable_string` instead of `envoy.string`, because `istio.hashable_string` is actually considered by Envoy when it makes the decision to multiplex. `istio.hashable_string` is equivalent to `envoy.hashable_string`, but `envoy.hashable_string` was introduced recently and is not available in all Envoy versions we need (and it will not be backported). So for the time being we will use our custom implementation and in a few quarters, once older versions of Istio fall off the support window, we can migrate everything to Envoy native `envoy.hashable_string`. The issue has not been caught by any of our tests, so this PR also modfies the ambient multicluster tests to catch this particular issue. From what I know it does not currently affect single-cluster deployments and waypoints (see #58630 (comment)), so it appears to be reasonable to just modify the multicluster tests. Fixes #58630 Signed-off-by: Mikhail Krinkin <[email protected]> * Add release notes for the bug fix Signed-off-by: Mikhail Krinkin <[email protected]> * Fix lint issues Signed-off-by: Mikhail Krinkin <[email protected]> --------- Signed-off-by: Mikhail Krinkin <[email protected]>
istio-testing
pushed a commit
to istio-testing/istio
that referenced
this pull request
Mar 18, 2026
…red with upstream This is the second part of the fix for istio#58630 (the first part was a change to the proxy to add support for istio.hashable_string in istio/proxy#6905). The brief summary of the problem is that multiple requests in Envoy can be multiplexed over the same connection pool, even when connecting to internal listeners. Envoy makes a decision on whether requests can be multiplexed together using various inputs, but when it decides to multiplex multiple requests together and use the same connection pool for those, it will share exactly the same filter state with the upstream, even if requests produced different filter state values. That happens because not all filter state value types are considered when Envoy makes the decision whether it should multiplex multiple requests together or not. In particular, Envoy does not consider filter states with type `envoy.string` when it decides to multiplex the requests. So currently if two requests have different authority in HBONE CONNECT request, they still can be multiplexed over the same connection pool in Envoy and only one of the authorites will actually be shared with the internal listener - that's not correct. For all filter state values that we share with upstream, going forward, we should use `istio.hashable_string` instead of `envoy.string`, because `istio.hashable_string` is actually considered by Envoy when it makes the decision to multiplex. `istio.hashable_string` is equivalent to `envoy.hashable_string`, but `envoy.hashable_string` was introduced recently and is not available in all Envoy versions we need (and it will not be backported). So for the time being we will use our custom implementation and in a few quarters, once older versions of Istio fall off the support window, we can migrate everything to Envoy native `envoy.hashable_string`. The issue has not been caught by any of our tests, so this PR also modfies the ambient multicluster tests to catch this particular issue. From what I know it does not currently affect single-cluster deployments and waypoints (see istio#58630 (comment)), so it appears to be reasonable to just modify the multicluster tests. Fixes istio#58630 Signed-off-by: Mikhail Krinkin <[email protected]>
istio-testing
added a commit
to istio/istio
that referenced
this pull request
Mar 19, 2026
…ilter state shared with upstream (#59524) * Switch to newly introduced istio.hashable_string for filter state shared with upstream This is the second part of the fix for #58630 (the first part was a change to the proxy to add support for istio.hashable_string in istio/proxy#6905). The brief summary of the problem is that multiple requests in Envoy can be multiplexed over the same connection pool, even when connecting to internal listeners. Envoy makes a decision on whether requests can be multiplexed together using various inputs, but when it decides to multiplex multiple requests together and use the same connection pool for those, it will share exactly the same filter state with the upstream, even if requests produced different filter state values. That happens because not all filter state value types are considered when Envoy makes the decision whether it should multiplex multiple requests together or not. In particular, Envoy does not consider filter states with type `envoy.string` when it decides to multiplex the requests. So currently if two requests have different authority in HBONE CONNECT request, they still can be multiplexed over the same connection pool in Envoy and only one of the authorites will actually be shared with the internal listener - that's not correct. For all filter state values that we share with upstream, going forward, we should use `istio.hashable_string` instead of `envoy.string`, because `istio.hashable_string` is actually considered by Envoy when it makes the decision to multiplex. `istio.hashable_string` is equivalent to `envoy.hashable_string`, but `envoy.hashable_string` was introduced recently and is not available in all Envoy versions we need (and it will not be backported). So for the time being we will use our custom implementation and in a few quarters, once older versions of Istio fall off the support window, we can migrate everything to Envoy native `envoy.hashable_string`. The issue has not been caught by any of our tests, so this PR also modfies the ambient multicluster tests to catch this particular issue. From what I know it does not currently affect single-cluster deployments and waypoints (see #58630 (comment)), so it appears to be reasonable to just modify the multicluster tests. Fixes #58630 Signed-off-by: Mikhail Krinkin <[email protected]> * Add release notes for the bug fix Signed-off-by: Mikhail Krinkin <[email protected]> * Fix lint issues Signed-off-by: Mikhail Krinkin <[email protected]> --------- Signed-off-by: Mikhail Krinkin <[email protected]> Co-authored-by: Mikhail Krinkin <[email protected]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What this PR does / why we need it:
This is part of the fix for istio/istio#58630 and you can find some additional context in that ticket (the other part will be to the pilot, and we'd also like to backport this change to 1.29 release branch as well).
To understand why this change is needed we have to start with some background.
In ambient multicluster, specifically in multi-network deployments, we rely on ambient E/W gateway to transfer data from one network to another.
When communicating across network boundaries in ambient we use double-HBONE (HBONE inside another HBONE). The E/W gateway terminate the outer HBONE tunnel and transfers the inner HBONE tunnel untouched to the destination.
Envoy configuration of ambient E/W gateway has two listeners important for understanding this change -
connect_terminateandmain_internal.connect_terminatelistener is responsible for terminating outer HBONE tunnel, extracting and preserving all the relevant routing information (e.g. authority from HTTP CONNECT request and some headers).However,
connect_terminatedoes not make any routing decisions, instead it passes all the relevant information to the internalmain_internallistener via filter state, and thenmain_internallistener is actually responsible for routing the request correctly.To transfer data to
main_internallistener,connect_terminatelistener opens an "internal" connection - it's a connection implemented purely in Envoy, but it implements the same interface as any other connections that Envoy supports and for many intents and purposes is not that different from say TCP connections.One thing that is particularly important for this PR is that Envoy does connection pooling for internal connections like it does for any other connections. Connections from the same pool assumed to share the same filter state (via transport socket options) with the upstream internal listener (e.g.,
main_internallistener in our case).So if you have two HTTP2 streams with different authority in the HBONE connect requests, only authority from the stream handled first will be communicated to the upstream internal listener - that's not what we want.
Envoy in principle recognizes that filter state may affect some routing decisions, so for some types of filter state objects shared with upstream Envoy can tell that it should use different connection pools to avoid mixing unrelated requests together, however
envoy.stringtype we currently use to communicate authority from the HBONE CONNECT requests is not one of such types.Recently, Envoy introduced
envoy.hashable_stringthat does what we need (see envoyproxy/envoy#43208), but this change didn't make it to Envoy 1.37 release branch and it will not be backported.NOTE: I checked other existing filter state object types, and they don't suit us either, so upstream Envoy
envoy.hashable_stringis basically the first and the only one that works for us.NOTE: From Envoy point of view that change is not a bug or security fix, so the fact that it should not be backported makes perfect sense, but just in case I also explicitly asked in that PR if we could backport it and got an explicit response that it's quite undesirable.
So this PR introduces
istio.hashable_stringwhich does exactly the same thing that upstreamenvoy.hashable_stringdoes, however we can backport it to the Istio's 1.29 release branch without relying on upstream Envoy. Eventually, we can phase it out in favor of the upstream Envoyenvoy.hashable_string.With the current Istio release cadence, according to https://istio.io/latest/docs/releases/supported-releases/, we should be able to phase it out completely in about 2 quarters and 6 weeks. Together with the fact that the extensions is quite small, I think that it's manageable to add it to the Istio proxy repor, even if it's not ideal.
Which issue this PR fixes (optional, in
fixes #<issue number>(, fixes #<issue_number>, ...)format, will close that issue when PR gets merged): fixes #Special notes for your reviewer:
I also considered an alternative solution of using
connection_pool_per_downstream_connectioncluster property supported by Envoy, but that solution does not work because ztunnels can actually multiplex HBONE connections targeting different services over the same HTTP2/TCP connection, so we can have this issue even with just one downstream connection in E/W gateway.+cc @grnmeira @keithmattix