-
Notifications
You must be signed in to change notification settings - Fork 587
fix auto http config with proxy protocol #7439
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
Changes from all commits
b849243
59ad5dd
e5f8ee3
cc8cff1
8787bfc
dc0046e
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -203,13 +203,6 @@ func buildXdsCluster(args *xdsClusterArgs) (*buildClusterResult, error) { | |
| } | ||
| } | ||
|
|
||
| // Set Proxy Protocol | ||
| if args.proxyProtocol != nil { | ||
| cluster.TransportSocket = buildProxyProtocolSocket(args.proxyProtocol, args.tSocket) | ||
| } else if args.tSocket != nil { | ||
| cluster.TransportSocket = args.tSocket | ||
| } | ||
|
|
||
| // scan through settings to determine cluster-level configuration options, as some of them | ||
| // influence transport socket specific settings | ||
| requiresAutoHTTPConfig := false | ||
|
|
@@ -235,15 +228,23 @@ func buildXdsCluster(args *xdsClusterArgs) (*buildClusterResult, error) { | |
| // only enable auto sni if TLS is configured | ||
| requiresAutoSNI := !hasLiteralSNI && requiresAutoHTTPConfig | ||
|
|
||
| // Set Proxy Protocol | ||
| proxyProtocolEnabled := args.proxyProtocol != nil | ||
| if proxyProtocolEnabled { | ||
| cluster.TransportSocket = buildProxyProtocolSocket(args.proxyProtocol, args.tSocket, requiresAutoHTTPConfig) | ||
| } else if args.tSocket != nil { | ||
| cluster.TransportSocket = args.tSocket | ||
| } | ||
|
|
||
| for i, ds := range args.settings { | ||
| if ds.TLS != nil { | ||
| socket, err := buildXdsUpstreamTLSSocketWthCert(ds.TLS, requiresAutoSNI, args.endpointType) | ||
| if err != nil { | ||
| // TODO: Log something here | ||
| return nil, err | ||
| } | ||
| if args.proxyProtocol != nil { | ||
| socket = buildProxyProtocolSocket(args.proxyProtocol, socket) | ||
| if proxyProtocolEnabled { | ||
| socket = buildProxyProtocolSocket(args.proxyProtocol, socket, requiresAutoHTTPConfig) | ||
| } | ||
| matchName := fmt.Sprintf("%s/tls/%d", args.name, i) | ||
|
|
||
|
|
@@ -265,7 +266,7 @@ func buildXdsCluster(args *xdsClusterArgs) (*buildClusterResult, error) { | |
| } | ||
|
|
||
| // TransportSocket is required for auto HTTP config | ||
| if requiresAutoHTTPConfig && cluster.TransportSocket == nil { | ||
| if requiresAutoHTTPConfig && cluster.TransportSocket == nil && !proxyProtocolEnabled { | ||
zirain marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| // we need a dummy transport socket to pass the validation | ||
| cluster.TransportSocket = dummyTransportSocket | ||
| } | ||
|
|
@@ -275,7 +276,8 @@ func buildXdsCluster(args *xdsClusterArgs) (*buildClusterResult, error) { | |
| if err != nil { | ||
| return nil, err | ||
| } | ||
| if epo != nil { | ||
| // Set TypedExtensionProtocolOptions if not using Proxy Protocol | ||
| if !proxyProtocolEnabled && epo != nil { | ||
| cluster.TypedExtensionProtocolOptions = epo | ||
| } | ||
|
|
||
|
|
@@ -1006,7 +1008,7 @@ func buildUpstreamCodecFilter() (*hcmv3.HttpFilter, error) { | |
| } | ||
|
|
||
| // buildProxyProtocolSocket builds the ProxyProtocol transport socket. | ||
| func buildProxyProtocolSocket(proxyProtocol *ir.ProxyProtocol, tSocket *corev3.TransportSocket) *corev3.TransportSocket { | ||
| func buildProxyProtocolSocket(proxyProtocol *ir.ProxyProtocol, tSocket *corev3.TransportSocket, requiresAutoHTTPConfig bool) *corev3.TransportSocket { | ||
| if proxyProtocol == nil { | ||
| return nil | ||
| } | ||
|
|
@@ -1026,18 +1028,22 @@ func buildProxyProtocolSocket(proxyProtocol *ir.ProxyProtocol, tSocket *corev3.T | |
|
|
||
| // If existing transport socket does not exist wrap around raw buffer | ||
| if tSocket == nil { | ||
| rawCtx := &rawbufferv3.RawBuffer{} | ||
| rawCtxAny, err := proto.ToAnyWithValidation(rawCtx) | ||
| if err != nil { | ||
| return nil | ||
| } | ||
| rawSocket := &corev3.TransportSocket{ | ||
| Name: wellknown.TransportSocketRawBuffer, | ||
| ConfigType: &corev3.TransportSocket_TypedConfig{ | ||
| TypedConfig: rawCtxAny, | ||
| }, | ||
| if requiresAutoHTTPConfig { | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. should this logic be } else if requiresAutoHTTPConfig { }. else. { }
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. the key is what should we do when tSocket is not nil and requiresAutoHTTPConfig is true.
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. if we ensure we execute tls logic before proxy procotol logic, then we can make sure this case never hits, and if |
||
| ppCtx.TransportSocket = dummyTransportSocket | ||
| } else { | ||
| rawCtx := &rawbufferv3.RawBuffer{} | ||
| rawCtxAny, err := proto.ToAnyWithValidation(rawCtx) | ||
| if err != nil { | ||
| return nil | ||
| } | ||
| rawSocket := &corev3.TransportSocket{ | ||
| Name: wellknown.TransportSocketRawBuffer, | ||
| ConfigType: &corev3.TransportSocket_TypedConfig{ | ||
| TypedConfig: rawCtxAny, | ||
| }, | ||
| } | ||
| ppCtx.TransportSocket = rawSocket | ||
| } | ||
| ppCtx.TransportSocket = rawSocket | ||
| } else { | ||
| ppCtx.TransportSocket = tSocket | ||
| } | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -89,8 +89,6 @@ http: | |
| roundRobin: | ||
| slowStart: | ||
| window: 5s | ||
| proxyProtocol: | ||
| version: V2 | ||
| tcpKeepalive: | ||
| probes: 7 | ||
| timeout: | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.