From 5568123464cad7d2573434af5951df8c4b3c4e8a Mon Sep 17 00:00:00 2001 From: zhangsetsail Date: Fri, 28 Apr 2023 12:37:00 +0800 Subject: [PATCH] perf: optimize the modification of rollout to httproute header --- pkg/trafficrouting/network/gateway/gateway.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/pkg/trafficrouting/network/gateway/gateway.go b/pkg/trafficrouting/network/gateway/gateway.go index 827beb7b..069da781 100644 --- a/pkg/trafficrouting/network/gateway/gateway.go +++ b/pkg/trafficrouting/network/gateway/gateway.go @@ -135,13 +135,13 @@ func (r *gatewayController) buildDesiredHTTPRoute(rules []gatewayv1alpha2.HTTPRo // according to the Gateway API definition, weight and headers cannot be supported at the same time. // A/B Testing, according to headers. current only support one match } else if len(matches) > 0 { - return r.buildCanaryHeaderHttpRoutes(rules, matches[0].Headers) + return r.buildCanaryHeaderHttpRoutes(rules, matches) } // canary release, according to percentage of traffic routing return r.buildCanaryWeightHttpRoutes(rules, weight) } -func (r *gatewayController) buildCanaryHeaderHttpRoutes(rules []gatewayv1alpha2.HTTPRouteRule, headers []gatewayv1alpha2.HTTPHeaderMatch) []gatewayv1alpha2.HTTPRouteRule { +func (r *gatewayController) buildCanaryHeaderHttpRoutes(rules []gatewayv1alpha2.HTTPRouteRule, matchs []rolloutv1alpha1.HttpRouteMatch) []gatewayv1alpha2.HTTPRouteRule { var desired []gatewayv1alpha2.HTTPRouteRule var canarys []gatewayv1alpha2.HTTPRouteRule for i := range rules { @@ -161,7 +161,7 @@ func (r *gatewayController) buildCanaryHeaderHttpRoutes(rules []gatewayv1alpha2. // set canary headers in httpRoute for j := range canaryRule.Matches { match := &canaryRule.Matches[j] - match.Headers = append(match.Headers, headers...) + match.Headers = append(match.Headers, matchs[j].Headers...) } canarys = append(canarys, *canaryRule) }