flagger icon indicating copy to clipboard operation
flagger copied to clipboard

fix virtual service destination routes when match is set

Open luisr-escobar opened this issue 1 year ago • 2 comments

primary destination is duplicated on both virtual service routes when setting match rules as per the istio a/b testing tutorial:

No weights set on analysis object:

  analysis:
    interval: 15s
    iterations: 2
    match:
    - headers:
        x-header-1:
          exact: Test_from_DEVs

The following is generated:

  http:
  - match:
    - headers:
        x-header-1:
          exact: Test_from_DEVs
    route:
    - destination:
        host: podinfo-primary
      weight: 100
    - destination:
        host: podinfo-canary
      weight: 0
  - route:
     - destination:
         host: podinfo-primary
       weight: 100

analysis values with weigths:

  analysis:
    interval: 15s
    match:
    - headers:
        x-header-1:
          exact: Test_from_DEVs
    maxWeight: 50
    stepWeight: 50
    threshold: 2

generates:

  http:
  - match:
    - headers:
        x-header-1:
          exact: Test_from_DEVs
    route:
    - destination:
        host: podinfo-primary
      weight: 50
    - destination:
        host: podinfo-canary
      weight: 50
  - route:
     - destination:
         host: podinfo-primary
       weight: 50

Logic comes from here and here

this PR makes canary the default destination from the canary route when neither maxWeight or stepWeight are set on the canary

  http:
  - match:
    - headers:
        x-header-1:
          exact: Test_from_DEVs
    route:
    - destination:
        host: podinfo-primary
      weight: 0
    - destination:
        host: podinfo-canary
      weight: 100
  - route:
    - destination:
        host: podinfo-primary
       weight: 100

Additionally as per istio docs If there is only one destination in a rule, it will receive all traffic so it probably makes sense to get rid of the weights altogether and only leave one destination on each route?

luisr-escobar avatar Jun 27 '24 13:06 luisr-escobar

@stefanprodan / @aryan9600 any chance one of you can take a look at this PR?

luisr-escobar avatar Jun 28 '24 19:06 luisr-escobar

.analysis.match and .analysis.stepWeight are not compatible with each other. the former is used for A/B testing while the latter is used for canary releases. if you'd like to combine both A/B testing with canary releases, you can do so by configuring session affinity: https://docs.flagger.app/tutorials/istio-progressive-delivery#session-affinity

aryan9600 avatar Oct 08 '24 19:10 aryan9600