Skip to content

Commit

Permalink
xds: always use :: and IPv4Compact for dynamic listener (#4743)
Browse files Browse the repository at this point in the history
* enable IPv4Compact

Signed-off-by: zirain <[email protected]>

* fix xds test

Signed-off-by: zirain <[email protected]>

* release-notes

Signed-off-by: zirain <[email protected]>

* nit

Signed-off-by: zirain <[email protected]>

* gen

Signed-off-by: zirain <[email protected]>

---------

Signed-off-by: zirain <[email protected]>
  • Loading branch information
zirain authored Nov 21, 2024
1 parent 2def6a4 commit 78da42c
Show file tree
Hide file tree
Showing 576 changed files with 993 additions and 814 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -886,7 +886,8 @@ xds:
path: /dev/stdout
address:
socketAddress:
address: 0.0.0.0
address: '::'
ipv4Compat: true
portValue: 10080
defaultFilterChain:
filters:
Expand Down Expand Up @@ -945,7 +946,8 @@ xds:
path: /dev/stdout
address:
socketAddress:
address: 0.0.0.0
address: '::'
ipv4Compat: true
portValue: 8080
defaultFilterChain:
filters:
Expand Down Expand Up @@ -1012,7 +1014,8 @@ xds:
path: /dev/stdout
address:
socketAddress:
address: 0.0.0.0
address: '::'
ipv4Compat: true
portValue: 1234
filterChains:
- filters:
Expand Down Expand Up @@ -1051,7 +1054,8 @@ xds:
path: /dev/stdout
address:
socketAddress:
address: 0.0.0.0
address: '::'
ipv4Compat: true
portValue: 8443
filterChains:
- filterChainMatch:
Expand Down Expand Up @@ -1097,7 +1101,8 @@ xds:
path: /dev/stdout
address:
socketAddress:
address: 0.0.0.0
address: '::'
ipv4Compat: true
portValue: 1234
protocol: UDP
listenerFilters:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -632,7 +632,8 @@
],
"address": {
"socketAddress": {
"address": "0.0.0.0",
"address": "::",
"ipv4Compat": true,
"portValue": 10080
}
},
Expand Down Expand Up @@ -723,7 +724,8 @@
],
"address": {
"socketAddress": {
"address": "0.0.0.0",
"address": "::",
"ipv4Compat": true,
"portValue": 8080
}
},
Expand Down Expand Up @@ -828,7 +830,8 @@
],
"address": {
"socketAddress": {
"address": "0.0.0.0",
"address": "::",
"ipv4Compat": true,
"portValue": 1234
}
},
Expand Down Expand Up @@ -893,7 +896,8 @@
],
"address": {
"socketAddress": {
"address": "0.0.0.0",
"address": "::",
"ipv4Compat": true,
"portValue": 8443
}
},
Expand Down Expand Up @@ -971,7 +975,8 @@
],
"address": {
"socketAddress": {
"address": "0.0.0.0",
"address": "::",
"ipv4Compat": true,
"portValue": 1234,
"protocol": "UDP"
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -365,7 +365,8 @@ xds:
path: /dev/stdout
address:
socketAddress:
address: 0.0.0.0
address: '::'
ipv4Compat: true
portValue: 10080
defaultFilterChain:
filters:
Expand Down Expand Up @@ -424,7 +425,8 @@ xds:
path: /dev/stdout
address:
socketAddress:
address: 0.0.0.0
address: '::'
ipv4Compat: true
portValue: 8080
defaultFilterChain:
filters:
Expand Down Expand Up @@ -491,7 +493,8 @@ xds:
path: /dev/stdout
address:
socketAddress:
address: 0.0.0.0
address: '::'
ipv4Compat: true
portValue: 1234
filterChains:
- filters:
Expand Down Expand Up @@ -530,7 +533,8 @@ xds:
path: /dev/stdout
address:
socketAddress:
address: 0.0.0.0
address: '::'
ipv4Compat: true
portValue: 8443
filterChains:
- filterChainMatch:
Expand Down Expand Up @@ -576,7 +580,8 @@ xds:
path: /dev/stdout
address:
socketAddress:
address: 0.0.0.0
address: '::'
ipv4Compat: true
portValue: 1234
protocol: UDP
listenerFilters:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@ xds:
path: /dev/stdout
address:
socketAddress:
address: 0.0.0.0
address: '::'
ipv4Compat: true
portValue: 10080
defaultFilterChain:
filters:
Expand Down Expand Up @@ -79,7 +80,8 @@ xds:
path: /dev/stdout
address:
socketAddress:
address: 0.0.0.0
address: '::'
ipv4Compat: true
portValue: 8080
defaultFilterChain:
filters:
Expand Down Expand Up @@ -146,7 +148,8 @@ xds:
path: /dev/stdout
address:
socketAddress:
address: 0.0.0.0
address: '::'
ipv4Compat: true
portValue: 1234
filterChains:
- filters:
Expand Down Expand Up @@ -185,7 +188,8 @@ xds:
path: /dev/stdout
address:
socketAddress:
address: 0.0.0.0
address: '::'
ipv4Compat: true
portValue: 8443
filterChains:
- filterChainMatch:
Expand Down Expand Up @@ -231,7 +235,8 @@ xds:
path: /dev/stdout
address:
socketAddress:
address: 0.0.0.0
address: '::'
ipv4Compat: true
portValue: 1234
protocol: UDP
listenerFilters:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -458,7 +458,8 @@
],
"address": {
"socketAddress": {
"address": "0.0.0.0",
"address": "::",
"ipv4Compat": true,
"portValue": 10080
}
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -263,7 +263,8 @@ xds:
path: /dev/stdout
address:
socketAddress:
address: 0.0.0.0
address: '::'
ipv4Compat: true
portValue: 10080
defaultFilterChain:
filters:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@ xds:
path: /dev/stdout
address:
socketAddress:
address: 0.0.0.0
address: '::'
ipv4Compat: true
portValue: 10080
defaultFilterChain:
filters:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,8 @@ xds:
path: /dev/stdout
address:
socketAddress:
address: 0.0.0.0
address: '::'
ipv4Compat: true
portValue: 10080
defaultFilterChain:
filters:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ xdsIR:
text:
- path: /dev/stdout
http:
- address: 0.0.0.0
- address: '::'
hostnames:
- '*'
isHTTP2: false
Expand Down
4 changes: 2 additions & 2 deletions internal/cmd/envoy/shutdown_manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ func Shutdown(drainTimeout time.Duration, minDrainDuration time.Duration, exitAt
// postEnvoyAdminAPI sends a POST request to the Envoy admin API
func postEnvoyAdminAPI(path string) error {
if resp, err := http.Post(fmt.Sprintf("http://%s:%d/%s",
bootstrap.EnvoyAdminAddress, bootstrap.EnvoyAdminPort, path), "application/json", nil); err != nil {
"localhost", bootstrap.EnvoyAdminPort, path), "application/json", nil); err != nil {
return err
} else {
defer resp.Body.Close()
Expand All @@ -187,7 +187,7 @@ func postEnvoyAdminAPI(path string) error {
func getTotalConnections() (*int, error) {
// Send request to Envoy admin API to retrieve server.total_connections stat
if resp, err := http.Get(fmt.Sprintf("http://%s:%d//stats?filter=^server\\.total_connections$&format=json",
bootstrap.EnvoyAdminAddress, bootstrap.EnvoyAdminPort)); err != nil {
"localhost", bootstrap.EnvoyAdminPort)); err != nil {
return nil, err
} else {
defer resp.Body.Close()
Expand Down
11 changes: 8 additions & 3 deletions internal/gatewayapi/listener.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import (
"github.com/envoyproxy/gateway/internal/ir"
"github.com/envoyproxy/gateway/internal/utils"
"github.com/envoyproxy/gateway/internal/utils/naming"
"github.com/envoyproxy/gateway/internal/utils/net"
)

var _ ListenersTranslator = (*Translator)(nil)
Expand Down Expand Up @@ -99,6 +100,10 @@ func (t *Translator) ProcessListeners(gateways []*GatewayContext, xdsIR resource
if !isReady {
continue
}

// EG always use `::` and set ipv4_compact with true to support both IPv4 and IPv6
address := net.IPv6ListenerAddress

// Add the listener to the Xds IR
servicePort := &protocolPort{protocol: listener.Protocol, port: int32(listener.Port)}
containerPort := servicePortToContainerPort(int32(listener.Port), gateway.envoyProxy)
Expand All @@ -107,7 +112,7 @@ func (t *Translator) ProcessListeners(gateways []*GatewayContext, xdsIR resource
irListener := &ir.HTTPListener{
CoreListenerDetails: ir.CoreListenerDetails{
Name: irListenerName(listener),
Address: "0.0.0.0",
Address: address,
Port: uint32(containerPort),
Metadata: buildListenerMetadata(listener, gateway),
IPFamily: getIPFamily(gateway.envoyProxy),
Expand All @@ -134,7 +139,7 @@ func (t *Translator) ProcessListeners(gateways []*GatewayContext, xdsIR resource
irListener := &ir.TCPListener{
CoreListenerDetails: ir.CoreListenerDetails{
Name: irListenerName(listener),
Address: "0.0.0.0",
Address: address,
Port: uint32(containerPort),
IPFamily: getIPFamily(gateway.envoyProxy),
},
Expand All @@ -150,7 +155,7 @@ func (t *Translator) ProcessListeners(gateways []*GatewayContext, xdsIR resource
irListener := &ir.UDPListener{
CoreListenerDetails: ir.CoreListenerDetails{
Name: irListenerName(listener),
Address: "0.0.0.0",
Address: address,
Port: uint32(containerPort),
},
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ xdsIR:
text:
- path: /dev/stdout
http:
- address: 0.0.0.0
- address: '::'
hostnames:
- '*'
isHTTP2: false
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ xdsIR:
text:
- path: /dev/stdout
http:
- address: 0.0.0.0
- address: '::'
hostnames:
- '*'
isHTTP2: false
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ xdsIR:
text:
- path: /dev/stdout
http:
- address: 0.0.0.0
- address: '::'
hostnames:
- '*'
isHTTP2: false
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ xdsIR:
text:
- path: /dev/stdout
http:
- address: 0.0.0.0
- address: '::'
hostnames:
- '*'
isHTTP2: false
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ xdsIR:
text:
- path: /dev/stdout
http:
- address: 0.0.0.0
- address: '::'
hostnames:
- '*'
isHTTP2: false
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -266,7 +266,7 @@ xdsIR:
text:
- path: /dev/stdout
http:
- address: 0.0.0.0
- address: '::'
hostnames:
- '*'
isHTTP2: false
Expand Down Expand Up @@ -323,7 +323,7 @@ xdsIR:
text:
- path: /dev/stdout
http:
- address: 0.0.0.0
- address: '::'
hostnames:
- '*'
isHTTP2: false
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,7 @@ xdsIR:
text:
- path: /dev/stdout
http:
- address: 0.0.0.0
- address: '::'
hostnames:
- '*'
isHTTP2: false
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ xdsIR:
text:
- path: /dev/stdout
http:
- address: 0.0.0.0
- address: '::'
hostnames:
- '*'
isHTTP2: false
Expand Down
Loading

0 comments on commit 78da42c

Please sign in to comment.