Skip to content

fix: auto detect upstream protocol#6792

Merged
arkodg merged 9 commits intoenvoyproxy:mainfrom
zirain:alpn/h2
Sep 25, 2025
Merged

fix: auto detect upstream protocol#6792
arkodg merged 9 commits intoenvoyproxy:mainfrom
zirain:alpn/h2

Conversation

@zirain
Copy link
Copy Markdown
Member

@zirain zirain commented Aug 15, 2025

This PR changed the default behavior when you enabled tls on EnvoyProxy but without alpn.
Before:

typedExtensionProtocolOptions unset, which means http1.

After:

AutoHttpConfig enabled, which means:

// Clusters configured with “AutoHttpConfig“ will use the highest available
// protocol; HTTP/2 if supported, otherwise HTTP/1.

@zirain zirain requested a review from a team as a code owner August 15, 2025 04:57
@codecov
Copy link
Copy Markdown

codecov bot commented Aug 15, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 71.05%. Comparing base (efc3d2c) to head (2938f7e).
⚠️ Report is 8 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #6792      +/-   ##
==========================================
+ Coverage   71.02%   71.05%   +0.02%     
==========================================
  Files         227      227              
  Lines       40331    40350      +19     
==========================================
+ Hits        28645    28670      +25     
+ Misses       9992     9987       -5     
+ Partials     1694     1693       -1     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@zirain zirain force-pushed the alpn/h2 branch 2 times, most recently from 04c3d7c to 51bf619 Compare August 24, 2025 16:27
@zirain zirain requested review from arkodg and guydc August 26, 2025 12:36
@arkodg
Copy link
Copy Markdown
Contributor

arkodg commented Sep 19, 2025

hey @zirain can you also update the doc string in

// +optional
that defaults to [http/1.1, h2]

and add a breaking changes note in the release notes

MaxVersion: ptr.To(egv1a1.TLSv13),
MinVersion: ptr.To(egv1a1.TLSv13),
MaxVersion: ptr.To(egv1a1.TLSv13),
ALPNProtocols: []egv1a1.ALPNProtocol{"http/1.1"},
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.

can we verify, http/1.1 is being used here ?

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.

%UPSTREAM_PROTOCOL% will help here, need more work.

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.

it's tested here:

for i, ds := range args.settings {
if ds.TLS != nil {
if !requiresAutoHTTPConfig && len(ds.TLS.ALPNProtocols) == 0 {
Copy link
Copy Markdown
Contributor

@arkodg arkodg Sep 22, 2025

Choose a reason for hiding this comment

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

this means, if ALPN is set to h2, it won't actually connect over h2 (without setting applicationProtocol in the backend), is that right ?

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.

if alpnProtocols = [h2], requiresAutoHTTPConfig is false, it should be same as the old logic which means use h2.
what I missed?

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.

imo we should use this for the default case when tls is non nil

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.

Priority
- Use Client Protocol
- Force H2 using Backend App Protocol or GRPCRoute ( isHTTP2)
- TLS != nil (AutoTLS)
- Default ( H1)

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.

cc @guydc

},
},
}
case requiresAutoHTTPConfig:
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.

should this be above requiresHTTP1Options ?

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.

Also above http2 options, if that's the case, right?

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.

I don't think it should be above http2 options because of the priority is as following:

Priority
- Use Client Protocol
- Force H2 using Backend App Protocol or GRPCRoute ( isHTTP2)
- TLS != nil (AutoTLS)
- Default ( H1)

@arkodg previous priority didn't point out the case of explicit http1 settings.

requiresHTTP1Options := args.http1Settings != nil &&
		(args.http1Settings.EnableTrailers || args.http1Settings.PreserveHeaderCase || args.http1Settings.HTTP10 != nil)

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.

yeah, I think this field should be renamed to hasHTTP1Options , and Auto tls should take precedence over it (it will also consume those http1 values)

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.

this PR won't be backported, let's discuss it in an seperated PR?

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.

right now if a user sets http1options and http2options in BTP for all routes, they cannot use auto TLS to decide the right proto to use per backend, which is why im recommending moving case requiresAutoHTTPConfig above case requiresHTTP1Options

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.

In that case, we might need more work about merge those options into auto.
That's why I proposal to do it in another PR, and also discuss guydc's 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.

sure follow up PR works

},
},
}
case requiresAutoHTTPConfig:
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.

Also above http2 options, if that's the case, right?

Signed-off-by: zirain <zirain2009@gmail.com>
Signed-off-by: zirain <zirain2009@gmail.com>
Signed-off-by: zirain <zirain2009@gmail.com>
Signed-off-by: zirain <zirain2009@gmail.com>
Signed-off-by: zirain <zirain2009@gmail.com>
Signed-off-by: zirain <zirain2009@gmail.com>
Signed-off-by: zirain <zirain2009@gmail.com>
Signed-off-by: zirain <zirain2009@gmail.com>
Signed-off-by: zirain <zirain2009@gmail.com>
@guydc
Copy link
Copy Markdown
Contributor

guydc commented Sep 24, 2025

In another issue, we should clarify how this field works. For example, what happens when:

  • Using grpc route/h2 proto but setting backend ALPN to [http/1.1] ? Would it break? would it be ignored?
  • Using preserve client proto but setting backend ALPN to [not-a-real-proto]
    etc.

I don't think that we can perform any sort of validation in this case to stop users from configuring bad values, since this value has meaning in the context of a specific backend, e.g. proxy has backends that grpc while others require auto and others preservation.

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.

3 participants