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
16 changes: 16 additions & 0 deletions internal/provider/kubernetes/indexers.go
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,22 @@ func backendHTTPRouteIndexFunc(rawObj client.Object) []string {
)
}
}

// Check for a RequestMirror filter to also include the backendRef from that filter
for _, filter := range rule.Filters {
if filter.Type != gwapiv1.HTTPRouteFilterRequestMirror {
continue
}

mirrorBackendRef := filter.RequestMirror.BackendRef

backendRefs = append(backendRefs,
types.NamespacedName{
Namespace: gatewayapi.NamespaceDerefOr(mirrorBackendRef.Namespace, httproute.Namespace),
Name: string(mirrorBackendRef.Name),
}.String(),
)
}
}
return backendRefs
}
Expand Down
46 changes: 46 additions & 0 deletions internal/provider/kubernetes/predicates_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -463,6 +463,52 @@ func TestValidateEndpointSliceForReconcile(t *testing.T) {
endpointSlice: test.GetEndpointSlice(types.NamespacedName{Name: "endpointslice"}, "imported-service", true),
expect: true,
},
{
name: "mirrored backend route exists",
configs: []client.Object{
test.GetGatewayClass("test-gc", egv1a1.GatewayControllerName, nil),
sampleGateway,
&gwapiv1.HTTPRoute{
ObjectMeta: metav1.ObjectMeta{
Name: "httproute-test",
},
Spec: gwapiv1.HTTPRouteSpec{
CommonRouteSpec: gwapiv1.CommonRouteSpec{
ParentRefs: []gwapiv1.ParentReference{
{Name: gwapiv1.ObjectName("scheduled-status-test")},
},
},
Rules: []gwapiv1.HTTPRouteRule{
{
BackendRefs: []gwapiv1.HTTPBackendRef{
{
BackendRef: gwapiv1.BackendRef{
BackendObjectReference: gwapiv1.BackendObjectReference{
Name: gwapiv1.ObjectName("service"),
Port: ptr.To(gwapiv1.PortNumber(80)),
},
},
},
},
Filters: []gwapiv1.HTTPRouteFilter{
{
Type: gwapiv1.HTTPRouteFilterRequestMirror,
RequestMirror: &gwapiv1.HTTPRequestMirrorFilter{
BackendRef: gwapiv1.BackendObjectReference{
Name: "mirror-service",
Port: ptr.To(gwapiv1.PortNumber(80)),
},
},
},
},
},
},
},
},
},
endpointSlice: test.GetEndpointSlice(types.NamespacedName{Name: "endpointslice"}, "mirror-service", false),
expect: true,
},
}

// Create the reconciler.
Expand Down