@@ -1124,7 +1124,7 @@ func (p *GatewayAPIProcessor) computeHTTPRouteForListener(route *gatewayapi_v1be
11241124 requestHeaderPolicy * HeadersPolicy
11251125 responseHeaderPolicy * HeadersPolicy
11261126 redirect * Redirect
1127- mirrorPolicy * MirrorPolicy
1127+ mirrorPolicies [] * MirrorPolicy
11281128 pathRewritePolicy * PathRewritePolicy
11291129 urlRewriteHostname string
11301130 )
@@ -1222,7 +1222,7 @@ func (p *GatewayAPIProcessor) computeHTTPRouteForListener(route *gatewayapi_v1be
12221222 PathRewritePolicy : pathRewritePolicy ,
12231223 }
12241224 case gatewayapi_v1beta1 .HTTPRouteFilterRequestMirror :
1225- if filter .RequestMirror == nil || mirrorPolicy != nil {
1225+ if filter .RequestMirror == nil {
12261226 continue
12271227 }
12281228
@@ -1231,12 +1231,12 @@ func (p *GatewayAPIProcessor) computeHTTPRouteForListener(route *gatewayapi_v1be
12311231 routeAccessor .AddCondition (gatewayapi_v1beta1 .RouteConditionType (cond .Type ), cond .Status , gatewayapi_v1beta1 .RouteConditionReason (cond .Reason ), cond .Message )
12321232 continue
12331233 }
1234- mirrorPolicy = & MirrorPolicy {
1234+ mirrorPolicies = append ( mirrorPolicies , & MirrorPolicy {
12351235 Cluster : & Cluster {
12361236 Upstream : mirrorService ,
12371237 },
12381238 Weight : 100 ,
1239- }
1239+ })
12401240 case gatewayapi_v1beta1 .HTTPRouteFilterURLRewrite :
12411241 if filter .URLRewrite == nil || pathRewritePolicy != nil {
12421242 continue
@@ -1337,7 +1337,7 @@ func (p *GatewayAPIProcessor) computeHTTPRouteForListener(route *gatewayapi_v1be
13371337 matchconditions ,
13381338 requestHeaderPolicy ,
13391339 responseHeaderPolicy ,
1340- mirrorPolicy ,
1340+ mirrorPolicies ,
13411341 clusters ,
13421342 totalWeight ,
13431343 priority ,
@@ -1403,7 +1403,7 @@ func (p *GatewayAPIProcessor) computeGRPCRouteForListener(route *gatewayapi_v1al
14031403 // Process rule-level filters.
14041404 var (
14051405 requestHeaderPolicy , responseHeaderPolicy * HeadersPolicy
1406- mirrorPolicy * MirrorPolicy
1406+ mirrorPolicies [] * MirrorPolicy
14071407 )
14081408
14091409 // Per Gateway API docs: "Specifying a core filter multiple times
@@ -1433,7 +1433,8 @@ func (p *GatewayAPIProcessor) computeGRPCRouteForListener(route *gatewayapi_v1al
14331433 routeAccessor .AddCondition (gatewayapi_v1beta1 .RouteConditionResolvedRefs , metav1 .ConditionFalse , status .ReasonDegraded , fmt .Sprintf ("%s on response headers" , err ))
14341434 }
14351435 case gatewayapi_v1alpha2 .GRPCRouteFilterRequestMirror :
1436- if filter .RequestMirror == nil || mirrorPolicy != nil {
1436+ // If more than one, we only take the first RequestMirror filter.
1437+ if filter .RequestMirror == nil || len (mirrorPolicies ) > 0 {
14371438 continue
14381439 }
14391440
@@ -1444,12 +1445,12 @@ func (p *GatewayAPIProcessor) computeGRPCRouteForListener(route *gatewayapi_v1al
14441445 }
14451446 // If protocol is not set on the service, need to set a default one based on listener's protocol type.
14461447 setDefaultServiceProtocol (mirrorService , listener .listener .Protocol )
1447- mirrorPolicy = & MirrorPolicy {
1448+ mirrorPolicies = append ( mirrorPolicies , & MirrorPolicy {
14481449 Cluster : & Cluster {
14491450 Upstream : mirrorService ,
14501451 },
14511452 Weight : 100 ,
1452- }
1453+ })
14531454 default :
14541455 routeAccessor .AddCondition (
14551456 gatewayapi_v1beta1 .RouteConditionAccepted ,
@@ -1481,7 +1482,7 @@ func (p *GatewayAPIProcessor) computeGRPCRouteForListener(route *gatewayapi_v1al
14811482 matchconditions ,
14821483 requestHeaderPolicy ,
14831484 responseHeaderPolicy ,
1484- mirrorPolicy ,
1485+ mirrorPolicies ,
14851486 clusters ,
14861487 totalWeight ,
14871488 priority ,
@@ -2043,7 +2044,7 @@ func (p *GatewayAPIProcessor) clusterRoutes(
20432044 matchConditions []* matchConditions ,
20442045 requestHeaderPolicy * HeadersPolicy ,
20452046 responseHeaderPolicy * HeadersPolicy ,
2046- mirrorPolicy * MirrorPolicy ,
2047+ mirrorPolicies [] * MirrorPolicy ,
20472048 clusters []* Cluster ,
20482049 totalWeight uint32 ,
20492050 priority uint8 ,
@@ -2071,7 +2072,7 @@ func (p *GatewayAPIProcessor) clusterRoutes(
20712072 QueryParamMatchConditions : mc .queryParams ,
20722073 RequestHeadersPolicy : requestHeaderPolicy ,
20732074 ResponseHeadersPolicy : responseHeaderPolicy ,
2074- MirrorPolicy : mirrorPolicy ,
2075+ MirrorPolicies : mirrorPolicies ,
20752076 Priority : priority ,
20762077 PathRewritePolicy : pathRewritePolicy ,
20772078 }
0 commit comments