-
Notifications
You must be signed in to change notification settings - Fork 84
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
upsteam protocol: add the ability to decide what protocol to use for upstream requests #697
Conversation
Signed-off-by: Jose Nino <[email protected]>
Signed-off-by: Jose Nino <[email protected]>
Signed-off-by: Jose Nino <[email protected]>
@@ -477,19 +477,38 @@ const LowerCaseString ClusterHeader{"x-envoy-mobile-cluster"}; | |||
const std::string BaseCluster = "base"; | |||
const std::string BaseWlanCluster = "base_wlan"; | |||
const std::string BaseWwanCluster = "base_wwan"; | |||
const LowerCaseString H2UpstreamHeader{"x-envoy-mobile-upstream-protocol"}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I propose simplifying this with a x-envoy-mobile-force-h2
header. If a header with this name is present assume inferred h2 support, if not, default to h1.
Signed-off-by: Jose Nino <[email protected]>
enum class UpstreamHttpProtocol(internal val stringValue: String) { | ||
HTTP1("http1"), | ||
HTTP2("http2"), | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can drop this enum if we just use a single header to force h2 (which is sort of non-standard anyways and only works with known destinations).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice work! Some suggestions to simplify this a bit.
Another approach would be to have an engine-level configuration option that allows you to specify authorities for which you know you can force h2. In some ways I like that better than a per-request approach, since support for this functionality is non-standard and relatively uncommon, and it avoids inadvertently dispatching requests to destinations that don't support it. It's more a property of the destination ( That said, I'm okay with the per-request approach as well (it just means the application will have to implement its own whitelist). |
@goaway thanks for all the comments. I am answering to all of them in aggregate because I think they are all related. I had originally written this PR with that approach, and actually with something similar to what you suggest below re: central configuration. However, I moved to this approach for a few reasons:
Right now absence of the header defaults us to http1 per the implementation in the Http::Dispatcher::setDestinationCluster. I can do:
per your suggestion make this setting a less strong requirement. I think this brings us closer to the sentiment of making this engine-level configuration without having to wire more configuration through. lmk what you think. |
Signed-off-by: Jose Nino <[email protected]>
Signed-off-by: Jose Nino <[email protected]>
library/kotlin/test/io/envoyproxy/envoymobile/RequestMapperTest.kt
Outdated
Show resolved
Hide resolved
A couple comments based on the discussions above: 1 (enum vs bool): If http2 were to be the only protocol we need to differentiate going forward, I think a boolean would be fine. However, since http3 is coming in the near future and we probably don't want to make protocol negotiation a hard blocker or to make breaking changes to the interfaces being introduced here, an enum seems like it'd probably make sense. 2 (engine versus request): Adding this information on a per-request basis is a bit more in line with how other configurations are set up now in Envoy Mobile. We moved to the dynamic forward proxy so that we no longer have to specify a fixed set of domains when starting the library, and requiring an http2 whitelist up front when starting up seems like a step backwards as it doesn't allow for new http2 domains to be discovered without restarting the library (not currently supported). Allowing this information to be specified per-request as a builder seems reasonable, especially considering @junr03 is stripping all |
Signed-off-by: Jose Nino <[email protected]>
Signed-off-by: Jose Nino <[email protected]>
Signed-off-by: Jose Nino <[email protected]>
Signed-off-by: Jose Nino <[email protected]>
Signed-off-by: Jose Nino <[email protected]>
library/kotlin/test/io/envoyproxy/envoymobile/RequestBuilderTest.kt
Outdated
Show resolved
Hide resolved
Signed-off-by: Jose Nino <[email protected]>
@rebello95 sorry wasn't ready for a pass. I think I hit all your comments. Let me take a look |
Signed-off-by: Jose Nino <[email protected]>
Signed-off-by: Jose Nino <[email protected]>
@@ -4,13 +4,17 @@ internal fun Request.outboundHeaders(): Map<String, List<String>> { | |||
val retryPolicyHeaders = retryPolicy?.outboundHeaders() ?: emptyMap() | |||
|
|||
val result = mutableMapOf<String, List<String>>() | |||
result.putAll(headers.filter { entry -> !entry.key.startsWith(":") }) | |||
result.putAll(headers.filter { entry -> !(entry.key.startsWith(":") || entry.key.startsWith("x-envoy-mobile"))}) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Up to you but using this might be more readable: !entry.key.startsWith(":") && !entry.key.startsWith("x-envoy-mobile")
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am always ambivalent about which one is more readable. I'll change to kick CI... 💩
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
😭
Signed-off-by: Jose Nino <[email protected]>
Signed-off-by: Michael Rebello <[email protected]>
Description: this PR adds the ability to decide what protocol to use for upstream requests. Note that this will be unnecessary once ALPN works for upstream requests (#502)
Risk Level: low
Testing: updated unit tests
Docs Changes: updated docs
Fixes #679
Signed-off-by: Jose Nino [email protected]