mirror of
https://github.com/fluxcd/flagger.git
synced 2026-04-15 06:57:34 +00:00
Fix HTTP URI match conditions
This commit is contained in:
@@ -347,7 +347,7 @@ You can enable A/B testing by specifying the HTTP match conditions and the numbe
|
||||
match:
|
||||
- headers:
|
||||
user-agent:
|
||||
regex: "^(?!.*Chrome)(?=.*\bSafari\b).*$"
|
||||
regex: "^(?!.*Chrome).*Safari.*"
|
||||
- headers:
|
||||
cookie:
|
||||
regex: "^(.*?;)?(user=test)(;.*)?$"
|
||||
|
||||
@@ -72,7 +72,7 @@ spec:
|
||||
match:
|
||||
- headers:
|
||||
user-agent:
|
||||
regex: "^(?!.*Chrome)(?=.*\bSafari\b).*$"
|
||||
regex: "^(?!.*Chrome).*Safari.*"
|
||||
- headers:
|
||||
cookie:
|
||||
regex: "^(.*?;)?(type=insider)(;.*)?$"
|
||||
|
||||
+15
-2
@@ -93,7 +93,7 @@ func (ir *IstioRouter) Sync(canary *flaggerv1.Canary) error {
|
||||
}
|
||||
|
||||
if len(canary.Spec.CanaryAnalysis.Match) > 0 {
|
||||
canaryMatch := append(canary.Spec.Service.Match, canary.Spec.CanaryAnalysis.Match...)
|
||||
canaryMatch := mergeMatchConditions(canary.Spec.CanaryAnalysis.Match, canary.Spec.Service.Match)
|
||||
newSpec.Http = []istiov1alpha3.HTTPRoute{
|
||||
{
|
||||
Match: canaryMatch,
|
||||
@@ -274,7 +274,7 @@ func (ir *IstioRouter) SetRoutes(
|
||||
// fix routing (A/B testing)
|
||||
if len(canary.Spec.CanaryAnalysis.Match) > 0 {
|
||||
// merge the common routes with the canary ones
|
||||
canaryMatch := append(canary.Spec.Service.Match, canary.Spec.CanaryAnalysis.Match...)
|
||||
canaryMatch := mergeMatchConditions(canary.Spec.CanaryAnalysis.Match, canary.Spec.Service.Match)
|
||||
vsCopy.Spec.Http = []istiov1alpha3.HTTPRoute{
|
||||
{
|
||||
Match: canaryMatch,
|
||||
@@ -345,3 +345,16 @@ func addHeaders(canary *flaggerv1.Canary) (headers map[string]string) {
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
// mergeMatchConditions appends the URI match rules to canary conditions
|
||||
func mergeMatchConditions(canary, defaults []istiov1alpha3.HTTPMatchRequest) []istiov1alpha3.HTTPMatchRequest {
|
||||
for i := range canary {
|
||||
for _, d := range defaults {
|
||||
if d.Uri != nil {
|
||||
canary[i].Uri = d.Uri
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return canary
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user