Skip to content

Commit

Permalink
perf: optimize the modification of rollout to httproute header
Browse files Browse the repository at this point in the history
  • Loading branch information
ZhangSetSail committed Apr 28, 2023
1 parent 5807b5b commit 5568123
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions pkg/trafficrouting/network/gateway/gateway.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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)
}
Expand Down

0 comments on commit 5568123

Please sign in to comment.