-
Notifications
You must be signed in to change notification settings - Fork 831
fix: resolve socket settings across listeners sharing an address and port #9673
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
Open
kadircanyildirm-crypto
wants to merge
1
commit into
envoyproxy:main
Choose a base branch
from
kadircanyildirm-crypto:fix/shared-socket-listener-settings
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
67 changes: 67 additions & 0 deletions
67
internal/xds/translator/testdata/in/xds-ir/multiple-listeners-same-port-socket-settings.yaml
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,67 @@ | ||
| # The listeners below all share the same address and port, so they collapse into a | ||
| # single xDS listener. The first one leaves every socket setting unset and must not | ||
| # make the shared socket fall back to the defaults: the buffer limit and the keepalive | ||
| # come from the second HTTP listener, and the max accept per socket event comes from | ||
| # the TCP listener. | ||
| http: | ||
| - name: "first-listener" | ||
| address: "::" | ||
| port: 10080 | ||
| hostnames: | ||
| - "foo.com" | ||
| path: | ||
| mergeSlashes: true | ||
| escapedSlashesAction: UnescapeAndRedirect | ||
| routes: | ||
| - name: "first-route" | ||
| hostname: "*" | ||
| destination: | ||
| name: "first-route-dest" | ||
| settings: | ||
| - endpoints: | ||
| - host: "1.2.3.4" | ||
| port: 50000 | ||
| name: "first-route-dest/backend/0" | ||
| - name: "second-listener" | ||
| address: "::" | ||
| port: 10080 | ||
| hostnames: | ||
| - "foo.net" | ||
| path: | ||
| mergeSlashes: true | ||
| escapedSlashesAction: UnescapeAndRedirect | ||
| tcpKeepalive: | ||
| probes: 7 | ||
| interval: 200 | ||
| idleTime: 50 | ||
| connection: | ||
| bufferLimit: 1048576 | ||
| routes: | ||
| - name: "second-route" | ||
| hostname: "*" | ||
| destination: | ||
| name: "second-route-dest" | ||
| settings: | ||
| - endpoints: | ||
| - host: "1.2.3.4" | ||
| port: 50000 | ||
| name: "second-route-dest/backend/0" | ||
| tcp: | ||
| - name: "third-listener" | ||
| address: "::" | ||
| port: 10080 | ||
| connection: | ||
| maxAcceptPerSocketEvent: 64 | ||
| routes: | ||
| - name: "third-route" | ||
| tls: | ||
| inspector: | ||
| snis: | ||
| - bar.com | ||
| destination: | ||
| name: "tcp-route-dest" | ||
| settings: | ||
| - endpoints: | ||
| - host: "1.2.3.4" | ||
| port: 50000 | ||
| name: "tcp-route-dest/backend/0" |
69 changes: 69 additions & 0 deletions
69
...translator/testdata/out/xds-ir/multiple-listeners-same-port-socket-settings.clusters.yaml
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,69 @@ | ||
| - circuitBreakers: | ||
| thresholds: | ||
| - maxRetries: 1024 | ||
| commonLbConfig: {} | ||
| connectTimeout: 10s | ||
| dnsLookupFamily: V4_PREFERRED | ||
| edsClusterConfig: | ||
| edsConfig: | ||
| ads: {} | ||
| resourceApiVersion: V3 | ||
| serviceName: first-route-dest | ||
| ignoreHealthOnHostRemoval: true | ||
| loadBalancingPolicy: | ||
| policies: | ||
| - typedExtensionConfig: | ||
| name: envoy.load_balancing_policies.least_request | ||
| typedConfig: | ||
| '@type': type.googleapis.com/envoy.extensions.load_balancing_policies.least_request.v3.LeastRequest | ||
| localityLbConfig: | ||
| localityWeightedLbConfig: {} | ||
| name: first-route-dest | ||
| perConnectionBufferLimitBytes: 32768 | ||
| type: EDS | ||
| - circuitBreakers: | ||
| thresholds: | ||
| - maxRetries: 1024 | ||
| commonLbConfig: {} | ||
| connectTimeout: 10s | ||
| dnsLookupFamily: V4_PREFERRED | ||
| edsClusterConfig: | ||
| edsConfig: | ||
| ads: {} | ||
| resourceApiVersion: V3 | ||
| serviceName: second-route-dest | ||
| ignoreHealthOnHostRemoval: true | ||
| loadBalancingPolicy: | ||
| policies: | ||
| - typedExtensionConfig: | ||
| name: envoy.load_balancing_policies.least_request | ||
| typedConfig: | ||
| '@type': type.googleapis.com/envoy.extensions.load_balancing_policies.least_request.v3.LeastRequest | ||
| localityLbConfig: | ||
| localityWeightedLbConfig: {} | ||
| name: second-route-dest | ||
| perConnectionBufferLimitBytes: 32768 | ||
| type: EDS | ||
| - circuitBreakers: | ||
| thresholds: | ||
| - maxRetries: 1024 | ||
| commonLbConfig: {} | ||
| connectTimeout: 10s | ||
| dnsLookupFamily: V4_PREFERRED | ||
| edsClusterConfig: | ||
| edsConfig: | ||
| ads: {} | ||
| resourceApiVersion: V3 | ||
| serviceName: tcp-route-dest | ||
| ignoreHealthOnHostRemoval: true | ||
| loadBalancingPolicy: | ||
| policies: | ||
| - typedExtensionConfig: | ||
| name: envoy.load_balancing_policies.least_request | ||
| typedConfig: | ||
| '@type': type.googleapis.com/envoy.extensions.load_balancing_policies.least_request.v3.LeastRequest | ||
| localityLbConfig: | ||
| localityWeightedLbConfig: {} | ||
| name: tcp-route-dest | ||
| perConnectionBufferLimitBytes: 32768 | ||
| type: EDS |
36 changes: 36 additions & 0 deletions
36
...ranslator/testdata/out/xds-ir/multiple-listeners-same-port-socket-settings.endpoints.yaml
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,36 @@ | ||
| - clusterName: first-route-dest | ||
| endpoints: | ||
| - lbEndpoints: | ||
| - endpoint: | ||
| address: | ||
| socketAddress: | ||
| address: 1.2.3.4 | ||
| portValue: 50000 | ||
| loadBalancingWeight: 1 | ||
| loadBalancingWeight: 1 | ||
| locality: | ||
| region: first-route-dest/backend/0 | ||
| - clusterName: second-route-dest | ||
| endpoints: | ||
| - lbEndpoints: | ||
| - endpoint: | ||
| address: | ||
| socketAddress: | ||
| address: 1.2.3.4 | ||
| portValue: 50000 | ||
| loadBalancingWeight: 1 | ||
| loadBalancingWeight: 1 | ||
| locality: | ||
| region: second-route-dest/backend/0 | ||
| - clusterName: tcp-route-dest | ||
| endpoints: | ||
| - lbEndpoints: | ||
| - endpoint: | ||
| address: | ||
| socketAddress: | ||
| address: 1.2.3.4 | ||
| portValue: 50000 | ||
| loadBalancingWeight: 1 | ||
| loadBalancingWeight: 1 | ||
| locality: | ||
| region: tcp-route-dest/backend/0 |
68 changes: 68 additions & 0 deletions
68
...ranslator/testdata/out/xds-ir/multiple-listeners-same-port-socket-settings.listeners.yaml
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,68 @@ | ||
| - address: | ||
| socketAddress: | ||
| address: '::' | ||
| portValue: 10080 | ||
| defaultFilterChain: | ||
| filters: | ||
| - name: envoy.filters.network.http_connection_manager | ||
| typedConfig: | ||
| '@type': type.googleapis.com/envoy.extensions.filters.network.http_connection_manager.v3.HttpConnectionManager | ||
| commonHttpProtocolOptions: | ||
| headersWithUnderscoresAction: REJECT_REQUEST | ||
| http2ProtocolOptions: | ||
| initialConnectionWindowSize: 1048576 | ||
| initialStreamWindowSize: 65536 | ||
| maxConcurrentStreams: 100 | ||
| httpFilters: | ||
| - name: envoy.filters.http.router | ||
| typedConfig: | ||
| '@type': type.googleapis.com/envoy.extensions.filters.http.router.v3.Router | ||
| suppressEnvoyHeaders: true | ||
| mergeSlashes: true | ||
| normalizePath: true | ||
| pathWithEscapedSlashesAction: UNESCAPE_AND_REDIRECT | ||
| rds: | ||
| configSource: | ||
| ads: {} | ||
| initialFetchTimeout: 0s | ||
| resourceApiVersion: V3 | ||
| routeConfigName: first-listener | ||
| serverHeaderTransformation: PASS_THROUGH | ||
| statPrefix: http-10080 | ||
| useRemoteAddress: true | ||
| name: first-listener | ||
| filterChains: | ||
| - filterChainMatch: | ||
| serverNames: | ||
| - bar.com | ||
| filters: | ||
| - name: envoy.filters.network.tcp_proxy | ||
| typedConfig: | ||
| '@type': type.googleapis.com/envoy.extensions.filters.network.tcp_proxy.v3.TcpProxy | ||
| cluster: tcp-route-dest | ||
| statPrefix: tls-passthrough-10080 | ||
| name: third-route | ||
| listenerFilters: | ||
| - name: envoy.filters.listener.tls_inspector | ||
| typedConfig: | ||
| '@type': type.googleapis.com/envoy.extensions.filters.listener.tls_inspector.v3.TlsInspector | ||
| maxConnectionsToAcceptPerSocketEvent: 64 | ||
| name: first-listener | ||
| perConnectionBufferLimitBytes: 1048576 | ||
| socketOptions: | ||
| - description: socket option to enable tcp keep alive | ||
| intValue: "1" | ||
| level: "1" | ||
| name: "9" | ||
| - description: socket option for keep alive probes | ||
| intValue: "7" | ||
| level: "6" | ||
| name: "6" | ||
| - description: socket option for keep alive idle time | ||
| intValue: "50" | ||
| level: "6" | ||
| name: "4" | ||
| - description: socket option for keep alive interval | ||
| intValue: "200" | ||
| level: "6" | ||
| name: "5" |
25 changes: 25 additions & 0 deletions
25
...s/translator/testdata/out/xds-ir/multiple-listeners-same-port-socket-settings.routes.yaml
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,25 @@ | ||
| - ignorePortInHostMatching: true | ||
| name: first-listener | ||
| virtualHosts: | ||
| - domains: | ||
| - '*' | ||
| name: first-listener/* | ||
| routes: | ||
| - match: | ||
| prefix: / | ||
| name: first-route | ||
| route: | ||
| cluster: first-route-dest | ||
| upgradeConfigs: | ||
| - upgradeType: websocket | ||
| - domains: | ||
| - '*' | ||
| name: second-listener/* | ||
| routes: | ||
| - match: | ||
| prefix: / | ||
| name: second-route | ||
| route: | ||
| cluster: second-route-dest | ||
| upgradeConfigs: | ||
| - upgradeType: websocket |
Oops, something went wrong.
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.
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.
With Gateway API input,
ClientConnection.MaxAcceptPerSocketEventis defaulted to1whenever a policy contains anyspec.connection(api/v1alpha1/connection_types.go:46), andbuildConnectioncopies any non-nil value into the IR. In a shared-port socket where an earlier listener sets onlyconnection.bufferLimitand a later listener explicitly setsmaxAcceptPerSocketEvent: 64, this merge records the defaulted1at the earlier listener and the later explicit value can never win, so the real Gateway API path still emits the default max accept that this PR is trying to stop from shadowing configured settings.Useful? React with 👍 / 👎.
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.
Good catch, and it is real — I checked the generated CRD and
maxAcceptPerSocketEventdoes carrydefault: 1(charts/gateway-crds-helm/templates/generated/gateway.envoyproxy.io_clienttrafficpolicies.yaml:208). So any ClientTrafficPolicy with aconnectionblock reaches the IR withMaxAcceptPerSocketEvent = 1even when the user never wrote it, andbuildConnectioncopies it through.Two things are tangled here, though.
The case this PR is for — a listener with no ClientTrafficPolicy at all — is unaffected:
buildConnection(nil)returns nil, so nothing is contributed and the configured listener wins. That is the case @zhaohuabing asked to fix unconditionally.Your case is a listener whose policy sets only
bufferLimit. From the IR that is indistinguishable from someone writingmaxAcceptPerSocketEvent: 1on purpose, because the defaulting happens in the API server before the controller ever sees the object. Under the rule we agreed on (when two listeners both set a field, the first wins and the status says so) it is technically correct — but it is a bad shape, since the user never typed that 1.The clean fix is to drop
+kubebuilder:default=1fromClientConnection.MaxAcceptPerSocketEvent.buildMaxAcceptPerSocketEventalready returns 1 for nil and is the only consumer of the field, so the emitted xDS would be byte-identical while the IR regains the unset-vs-set distinction. That is a change under/apithough, which the contributing guide wants agreed before implementation.@zhaohuabing — happy to do it either way: fold it into this PR, or send it as its own small API PR and rebase this one on top. Which do you prefer?