Skip to content

Commit

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

* 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]>
(cherry picked from commit 78da42c)
Signed-off-by: Huabing Zhao <[email protected]>
  • Loading branch information
zirain authored and zhaohuabing committed Nov 22, 2024
1 parent 067efab commit 222a0f2
Show file tree
Hide file tree
Showing 576 changed files with 1,332 additions and 812 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -891,7 +891,8 @@ xds:
path: /dev/stdout
address:
socketAddress:
address: 0.0.0.0
address: '::'
ipv4Compat: true
portValue: 10080
defaultFilterChain:
filters:
Expand Down Expand Up @@ -950,7 +951,8 @@ xds:
path: /dev/stdout
address:
socketAddress:
address: 0.0.0.0
address: '::'
ipv4Compat: true
portValue: 8080
defaultFilterChain:
filters:
Expand Down Expand Up @@ -1017,7 +1019,8 @@ xds:
path: /dev/stdout
address:
socketAddress:
address: 0.0.0.0
address: '::'
ipv4Compat: true
portValue: 1234
filterChains:
- filters:
Expand Down Expand Up @@ -1056,7 +1059,8 @@ xds:
path: /dev/stdout
address:
socketAddress:
address: 0.0.0.0
address: '::'
ipv4Compat: true
portValue: 8443
filterChains:
- filterChainMatch:
Expand Down Expand Up @@ -1102,7 +1106,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 @@ -637,7 +637,8 @@
],
"address": {
"socketAddress": {
"address": "0.0.0.0",
"address": "::",
"ipv4Compat": true,
"portValue": 10080
}
},
Expand Down Expand Up @@ -728,7 +729,8 @@
],
"address": {
"socketAddress": {
"address": "0.0.0.0",
"address": "::",
"ipv4Compat": true,
"portValue": 8080
}
},
Expand Down Expand Up @@ -833,7 +835,8 @@
],
"address": {
"socketAddress": {
"address": "0.0.0.0",
"address": "::",
"ipv4Compat": true,
"portValue": 1234
}
},
Expand Down Expand Up @@ -898,7 +901,8 @@
],
"address": {
"socketAddress": {
"address": "0.0.0.0",
"address": "::",
"ipv4Compat": true,
"portValue": 8443
}
},
Expand Down Expand Up @@ -976,7 +980,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 @@ -370,7 +370,8 @@ xds:
path: /dev/stdout
address:
socketAddress:
address: 0.0.0.0
address: '::'
ipv4Compat: true
portValue: 10080
defaultFilterChain:
filters:
Expand Down Expand Up @@ -429,7 +430,8 @@ xds:
path: /dev/stdout
address:
socketAddress:
address: 0.0.0.0
address: '::'
ipv4Compat: true
portValue: 8080
defaultFilterChain:
filters:
Expand Down Expand Up @@ -496,7 +498,8 @@ xds:
path: /dev/stdout
address:
socketAddress:
address: 0.0.0.0
address: '::'
ipv4Compat: true
portValue: 1234
filterChains:
- filters:
Expand Down Expand Up @@ -535,7 +538,8 @@ xds:
path: /dev/stdout
address:
socketAddress:
address: 0.0.0.0
address: '::'
ipv4Compat: true
portValue: 8443
filterChains:
- filterChainMatch:
Expand Down Expand Up @@ -581,7 +585,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 @@ -460,7 +460,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 @@ -265,7 +265,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 @@ -227,7 +227,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 222a0f2

Please sign in to comment.