Skip to content
Open
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
2 changes: 1 addition & 1 deletion internal/gatewayapi/listener.go
Original file line number Diff line number Diff line change
Expand Up @@ -950,7 +950,7 @@ func (t *Translator) processBackendRefs(name string, backendCluster egv1a1.Backe
}
result = append(result, ds)
case resource.KindBackend:
if err := t.validateBackendRefBackend(ref.BackendObjectReference, resources, ns, true); err != nil {
if err := t.validateBackendRefBackend(ref.BackendObjectReference, resources, ns); err != nil {
return nil, nil, err
}
ds := t.processBackendDestinationSetting(name, ref.BackendObjectReference, ns, ir.TCP)
Expand Down
11 changes: 9 additions & 2 deletions internal/gatewayapi/route.go
Original file line number Diff line number Diff line change
Expand Up @@ -1957,7 +1957,7 @@ func validateDestinationSettings(destinationSettings *ir.DestinationSetting, isS
case egv1a1.KindBackend:
if destinationSettings.AddressType != nil && *destinationSettings.AddressType == ir.MIXED {
return status.NewRouteStatusError(
fmt.Errorf("mixed FQDN and IP or Unix address type for the same backendRef is not supported"),
fmt.Errorf("mixed FQDN with IP or Unix address type for the same backendRef is not supported"),
status.RouteReasonUnsupportedAddressType)
}
case resource.KindService, resource.KindServiceImport:
Expand Down Expand Up @@ -2505,7 +2505,14 @@ func (t *Translator) processBackendDestinationSetting(
}

if len(addrTypeMap) > 0 && dstAddrType == nil {
dstAddrType = ptr.To(ir.MIXED)
// IP + UDS mixing is supported by Envoy (both are static endpoint types).
// Only classify as MIXED when FQDN is involved, which requires different
// cluster resolution and cannot share a cluster with IP/UDS endpoints.
if len(addrTypeMap) == 2 && addrTypeMap[ir.IP] > 0 && addrTypeMap[ir.UDS] > 0 {
dstAddrType = ptr.To(ir.IP)
} else {
dstAddrType = ptr.To(ir.MIXED)
}
}

ds.Endpoints = dstEndpoints
Expand Down
31 changes: 31 additions & 0 deletions internal/gatewayapi/route_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -376,6 +376,37 @@ func TestValidateDestinationSettings(t *testing.T) {
wantErr: true,
wantReason: status.RouteReasonUnsupportedAddressType,
},
{
name: "mixed FQDN address type rejected for Backend",
ds: &ir.DestinationSetting{
Name: "mixed-fqdn",
Endpoints: []*ir.DestinationEndpoint{{Host: "10.0.0.1"}},
AddressType: ptr.To(ir.MIXED),
},
kind: ptr.To(gwapiv1.Kind(egv1a1.KindBackend)),
wantErr: true,
wantReason: status.RouteReasonUnsupportedAddressType,
},
{
name: "IP address type allowed for Backend",
ds: &ir.DestinationSetting{
Name: "ip-only",
Endpoints: []*ir.DestinationEndpoint{{Host: "10.0.0.1"}},
AddressType: ptr.To(ir.IP),
},
kind: ptr.To(gwapiv1.Kind(egv1a1.KindBackend)),
wantErr: false,
},
{
name: "UDS address type allowed for Backend",
ds: &ir.DestinationSetting{
Name: "uds-only",
Endpoints: []*ir.DestinationEndpoint{{Path: ptr.To("/var/run/backend.sock")}},
AddressType: ptr.To(ir.UDS),
},
kind: ptr.To(gwapiv1.Kind(egv1a1.KindBackend)),
wantErr: false,
},
}

for _, tt := range tests {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -151,10 +151,9 @@ httpRoutes:
status: "True"
type: Accepted
- lastTransitionTime: null
message: 'Failed to process route rule 0 backendRef 0: unix domain sockets
are not supported in backend references.'
reason: UnsupportedAddressType
status: "False"
message: Resolved all the Object references for the Route
reason: ResolvedRefs
status: "True"
type: ResolvedRefs
controllerName: gateway.envoyproxy.io/gatewayclass-controller
parentRef:
Expand Down Expand Up @@ -366,8 +365,25 @@ xdsIR:
mergeSlashes: true
port: 80
routes:
- directResponse:
statusCode: 500
- destination:
metadata:
kind: HTTPRoute
name: httproute-1
namespace: default
name: httproute/default/httproute-1/rule/0
settings:
- addressType: UDS
endpoints:
- host: ""
path: /var/run/backend.sock
port: 0
metadata:
kind: Backend
name: backend-uds
namespace: default
name: httproute/default/httproute-1/rule/0/backend/0
protocol: HTTP
weight: 1
hostname: '*'
isHTTP2: false
metadata:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -145,10 +145,9 @@ httpRoutes:
status: "True"
type: Accepted
- lastTransitionTime: null
message: 'Failed to process route rule 0 backendRef 0: unix domain sockets
are not supported in backend references.'
reason: UnsupportedAddressType
status: "False"
message: Resolved all the Object references for the Route
reason: ResolvedRefs
status: "True"
type: ResolvedRefs
controllerName: gateway.envoyproxy.io/gatewayclass-controller
parentRef:
Expand Down Expand Up @@ -182,8 +181,8 @@ httpRoutes:
status: "True"
type: Accepted
- lastTransitionTime: null
message: 'Failed to process route rule 0 backendRef 0: mixed FQDN and IP or
Unix address type for the same backendRef is not supported.'
message: 'Failed to process route rule 0 backendRef 0: mixed FQDN with IP
or Unix address type for the same backendRef is not supported.'
reason: UnsupportedAddressType
status: "False"
type: ResolvedRefs
Expand Down Expand Up @@ -219,8 +218,8 @@ httpRoutes:
status: "True"
type: Accepted
- lastTransitionTime: null
message: 'Failed to process route rule 0 backendRef 0: mixed FQDN and IP or
Unix address type for the same backendRef is not supported.'
message: 'Failed to process route rule 0 backendRef 0: mixed FQDN with IP
or Unix address type for the same backendRef is not supported.'
reason: UnsupportedAddressType
status: "False"
type: ResolvedRefs
Expand Down Expand Up @@ -290,8 +289,27 @@ xdsIR:
mergeSlashes: true
port: 10080
routes:
- directResponse:
statusCode: 500
- destination:
metadata:
kind: HTTPRoute
name: httproute-1
namespace: default
name: httproute/default/httproute-1/rule/0
settings:
- addressType: IP
endpoints:
- host: ""
path: /var/run/backend.sock
port: 0
- host: 1.1.1.1
port: 3001
metadata:
kind: Backend
name: backend-ip-uds-mixed
namespace: default
name: httproute/default/httproute-1/rule/0/backend/0
protocol: HTTP
weight: 1
hostname: '*'
isHTTP2: false
metadata:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -153,10 +153,9 @@ httpRoutes:
status: "True"
type: Accepted
- lastTransitionTime: null
message: 'Failed to process route rule 0 backendRef 0: unix domain sockets
are not supported in backend references.'
reason: UnsupportedAddressType
status: "False"
message: Resolved all the Object references for the Route
reason: ResolvedRefs
status: "True"
type: ResolvedRefs
controllerName: gateway.envoyproxy.io/gatewayclass-controller
parentRef:
Expand Down Expand Up @@ -370,8 +369,25 @@ xdsIR:
mergeSlashes: true
port: 10080
routes:
- directResponse:
statusCode: 500
- destination:
metadata:
kind: HTTPRoute
name: httproute-1
namespace: default
name: httproute/default/httproute-1/rule/0
settings:
- addressType: UDS
endpoints:
- host: ""
path: /var/run/backend.sock
port: 0
metadata:
kind: Backend
name: backend-uds
namespace: default
name: httproute/default/httproute-1/rule/0/backend/0
protocol: HTTP
weight: 1
hostname: '*'
isHTTP2: false
metadata:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -123,10 +123,9 @@ httpRoutes:
status: "True"
type: Accepted
- lastTransitionTime: null
message: 'Failed to process route rule 0 backendRef 0: unix domain sockets
are not supported in backend references.'
reason: UnsupportedAddressType
status: "False"
message: Resolved all the Object references for the Route
reason: ResolvedRefs
status: "True"
type: ResolvedRefs
controllerName: gateway.envoyproxy.io/gatewayclass-controller
parentRef:
Expand Down Expand Up @@ -163,10 +162,9 @@ httpRoutes:
status: "True"
type: Accepted
- lastTransitionTime: null
message: 'Failed to process route rule 0 backendRef 0: unix domain sockets
are not supported in backend references.'
reason: UnsupportedAddressType
status: "False"
message: Resolved all the Object references for the Route
reason: ResolvedRefs
status: "True"
type: ResolvedRefs
controllerName: gateway.envoyproxy.io/gatewayclass-controller
parentRef:
Expand Down Expand Up @@ -242,10 +240,9 @@ httpRoutes:
status: "True"
type: Accepted
- lastTransitionTime: null
message: 'Failed to process route rule 0 backendRef 0: unix domain sockets
are not supported in backend references.'
reason: UnsupportedAddressType
status: "False"
message: Resolved all the Object references for the Route
reason: ResolvedRefs
status: "True"
type: ResolvedRefs
controllerName: gateway.envoyproxy.io/gatewayclass-controller
parentRef:
Expand Down Expand Up @@ -320,8 +317,17 @@ xdsIR:
namespace: default
name: httproute/default/httproute-1/rule/0
settings:
- invalid: true
- addressType: UDS
endpoints:
- host: ""
path: /var/run/backend.sock
port: 0
metadata:
kind: Backend
name: backend-uds
namespace: default
name: httproute/default/httproute-1/rule/0/backend/0
protocol: HTTP
weight: 1
- addressType: IP
endpoints:
Expand Down Expand Up @@ -363,8 +369,17 @@ xdsIR:
namespace: default
name: httproute/default/httproute-2/rule/0
settings:
- invalid: true
- addressType: UDS
endpoints:
- host: ""
path: /var/run/backend.sock
port: 0
metadata:
kind: Backend
name: backend-uds
namespace: default
name: httproute/default/httproute-2/rule/0/backend/0
protocol: HTTP
weight: 1
- addressType: IP
endpoints:
Expand Down Expand Up @@ -435,8 +450,17 @@ xdsIR:
namespace: default
name: httproute/default/httproute-3/rule/0
settings:
- invalid: true
- addressType: UDS
endpoints:
- host: ""
path: /var/run/backend.sock
port: 0
metadata:
kind: Backend
name: backend-uds
namespace: default
name: httproute/default/httproute-3/rule/0/backend/0
protocol: HTTP
weight: 1
- addressType: FQDN
endpoints:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -170,11 +170,9 @@ httpRoutes:
status: "True"
type: Accepted
- lastTransitionTime: null
message: |-
Failed to process route rule 0 backendRef 0: unix domain sockets are not supported in backend references.
Failed to process route rule 0 backendRef 1: unix domain sockets are not supported in backend references.
reason: UnsupportedAddressType
status: "False"
message: Resolved all the Object references for the Route
reason: ResolvedRefs
status: "True"
type: ResolvedRefs
controllerName: gateway.envoyproxy.io/gatewayclass-controller
parentRef:
Expand Down Expand Up @@ -320,8 +318,37 @@ xdsIR:
mergeSlashes: true
port: 10080
routes:
- directResponse:
statusCode: 500
- destination:
metadata:
kind: HTTPRoute
name: httproute-1
namespace: default
name: httproute/default/httproute-1/rule/0
settings:
- addressType: UDS
endpoints:
- host: ""
path: /var/run/backend.sock
port: 0
metadata:
kind: Backend
name: backend-uds
namespace: default
name: httproute/default/httproute-1/rule/0/backend/0
protocol: HTTP
weight: 1
- addressType: UDS
endpoints:
- host: ""
path: /var/run/backend2.sock
port: 0
metadata:
kind: Backend
name: backend-uds2
namespace: default
name: httproute/default/httproute-1/rule/0/backend/1
protocol: HTTP
weight: 1
hostname: '*'
isHTTP2: false
metadata:
Expand Down
Loading
Loading