Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 17 additions & 9 deletions internal/gatewayapi/listener.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
"errors"
"fmt"
"math"
"net"
"strings"

"github.com/google/cel-go/cel"
Expand All @@ -24,7 +25,7 @@
"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"
netutils "github.com/envoyproxy/gateway/internal/utils/net"
"github.com/envoyproxy/gateway/internal/xds/bootstrap"
)

Expand Down Expand Up @@ -105,10 +106,10 @@
continue
}

address := net.IPv4ListenerAddress
address := netutils.IPv4ListenerAddress
ipFamily := getEnvoyIPFamily(gateway.envoyProxy)
if ipFamily != nil && (*ipFamily == egv1a1.IPv6 || *ipFamily == egv1a1.DualStack) {
address = net.IPv6ListenerAddress
address = netutils.IPv6ListenerAddress

Check warning on line 112 in internal/gatewayapi/listener.go

View check run for this annotation

Codecov / codecov/patch

internal/gatewayapi/listener.go#L112

Added line #L112 was not covered by tests
}

// Add the listener to the Xds IR
Expand Down Expand Up @@ -434,14 +435,14 @@
func (t *Translator) processProxyReadyListener(xdsIR *ir.Xds, envoyProxy *egv1a1.EnvoyProxy) {
var (
ipFamily = egv1a1.IPv4
address = net.IPv4ListenerAddress
address = netutils.IPv4ListenerAddress
)

if envoyProxy != nil && envoyProxy.Spec.IPFamily != nil {
ipFamily = *envoyProxy.Spec.IPFamily
}
if ipFamily == egv1a1.IPv6 || ipFamily == egv1a1.DualStack {
address = net.IPv6ListenerAddress
address = netutils.IPv6ListenerAddress

Check warning on line 445 in internal/gatewayapi/listener.go

View check run for this annotation

Codecov / codecov/patch

internal/gatewayapi/listener.go#L445

Added line #L445 was not covered by tests
}

xdsIR.ReadyListener = &ir.ReadyListener{
Expand Down Expand Up @@ -835,12 +836,19 @@
}

func destinationSettingFromHostAndPort(name, host string, port uint32) []*ir.DestinationSetting {
// check if host is an IP address or a hostname
addressType := ir.FQDN
if net.ParseIP(host) != nil {
addressType = ir.IP
}

Check warning on line 843 in internal/gatewayapi/listener.go

View check run for this annotation

Codecov / codecov/patch

internal/gatewayapi/listener.go#L842-L843

Added lines #L842 - L843 were not covered by tests

return []*ir.DestinationSetting{
{
Name: name,
Weight: ptr.To[uint32](1),
Protocol: ir.GRPC,
Endpoints: []*ir.DestinationEndpoint{ir.NewDestEndpoint(host, port, false, nil)},
Name: name,
Weight: ptr.To[uint32](1),
Protocol: ir.GRPC,
AddressType: ptr.To(addressType),
Endpoints: []*ir.DestinationEndpoint{ir.NewDestEndpoint(host, port, false, nil)},
},
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,8 @@ xdsIR:
namespace: envoy-gateway-system
name: accesslog_otel_0_1
settings:
- endpoints:
- addressType: FQDN
endpoints:
- host: otel-collector.monitoring.svc.cluster.local
port: 4317
name: accesslog_otel_0_1/backend/-1
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -445,7 +445,8 @@ xdsIR:
namespace: envoy-gateway-system
name: accesslog_otel_2_3
settings:
- endpoints:
- addressType: FQDN
endpoints:
- host: otel-collector.monitoring.svc.cluster.local
port: 4317
name: accesslog_otel_2_3/backend/-1
Expand All @@ -464,7 +465,8 @@ xdsIR:
namespace: envoy-gateway-system
name: accesslog_otel_3_3
settings:
- endpoints:
- addressType: FQDN
endpoints:
- host: otel-collector.monitoring.svc.cluster.local
port: 4317
name: accesslog_otel_3_3/backend/-1
Expand All @@ -483,7 +485,8 @@ xdsIR:
namespace: envoy-gateway-system
name: accesslog_otel_4_3
settings:
- endpoints:
- addressType: FQDN
endpoints:
- host: otel-collector.monitoring.svc.cluster.local
port: 4317
name: accesslog_otel_4_3/backend/-1
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -299,7 +299,8 @@ xdsIR:
namespace: envoy-gateway-system
name: accesslog_otel_0_3
settings:
- endpoints:
- addressType: FQDN
endpoints:
- host: otel-collector.monitoring.svc.cluster.local
port: 4317
name: accesslog_otel_0_3/backend/-1
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,8 @@ xdsIR:
namespace: envoy-gateway-system
name: accesslog_otel_0_3
settings:
- endpoints:
- addressType: FQDN
endpoints:
- host: otel-collector.monitoring.svc.cluster.local
port: 4317
name: accesslog_otel_0_3/backend/-1
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,8 @@ xdsIR:
namespace: envoy-gateway-system
name: accesslog_otel_0_3
settings:
- endpoints:
- addressType: FQDN
endpoints:
- host: otel-collector.monitoring.svc.cluster.local
port: 4317
name: accesslog_otel_0_3/backend/-1
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,8 @@ xdsIR:
namespace: envoy-gateway
name: tracing
settings:
- endpoints:
- addressType: FQDN
endpoints:
- host: otel-collector.monitoring.svc.cluster.local
port: 4317
name: tracing/backend/-1
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,8 @@ xdsIR:
namespace: envoy-gateway
name: tracing
settings:
- endpoints:
- addressType: FQDN
endpoints:
- host: otel-collector.monitoring.svc.cluster.local
port: 4317
name: tracing/backend/-1
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -350,7 +350,8 @@ xdsIR:
namespace: envoy-gateway
name: tracing
settings:
- endpoints:
- addressType: FQDN
endpoints:
- host: otel-collector.monitoring.svc.cluster.local
port: 4317
name: tracing/backend/-1
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -321,7 +321,8 @@ xdsIR:
namespace: envoy-gateway
name: tracing
settings:
- endpoints:
- addressType: FQDN
endpoints:
- host: otel-collector.monitoring.svc.cluster.local
port: 4317
name: tracing/backend/-1
Expand Down Expand Up @@ -410,7 +411,8 @@ xdsIR:
namespace: envoy-gateway
name: tracing
settings:
- endpoints:
- addressType: FQDN
endpoints:
- host: otel-collector.monitoring.svc.cluster.local
port: 4317
name: tracing/backend/-1
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -352,7 +352,8 @@ xdsIR:
namespace: envoy-gateway
name: tracing
settings:
- endpoints:
- addressType: FQDN
endpoints:
- host: otel-collector.monitoring.svc.cluster.local
port: 4317
name: tracing/backend/-1
Expand Down