contour: Mirroring doesn't work correctly with weights

I specified this proxy:

apiVersion: projectcontour.io/v1
kind: HTTPProxy
metadata:
  name: artifactory-v2
spec:
  routes:
    services:
    - name: artifactory-prod
      port: 80
      weight: 95
    - service: artifactory-dev
      port: 80
      weight: 4
    - service: artifactory-sampler
      port: 80
      weight: 1
      mirror: true

And my expectation was that 1% of traffic would be mirrored to artifactory-sampler. However, the envoy configuration ends up like this:

         "routes": [
            {
              "match": {
                "prefix": "/v2/token/"
              },
              "route": {
                "weighted_clusters": {
                  "clusters": [
                    {
                      "name": "default/artifactory-dev/80/da39a3ee5e",
                      "weight": 4
                    },
                    {
                      "name": "default/artifactory-prod/80/da39a3ee5e",
                      "weight": 95
                    }
                  ],
                  "total_weight": 99
                },
                "request_mirror_policy": {
                  "cluster": "default/artifactory-sampler/80/da39a3ee5e"
                }
              }
            },
            {
              "match": {
                "prefix": "/v1/token/"
              },
              "route": {
                "weighted_clusters": {
                  "clusters": [
                    {
                      "name": "default/artifactory-dev/80/da39a3ee5e",
                      "weight": 4
                    },
                    {
                      "name": "default/artifactory-prod/80/da39a3ee5e",
                      "weight": 95
                    }
                  ],
                  "total_weight": 99
                },
                "request_mirror_policy": {
                  "cluster": "default/artifactory-sampler/80/da39a3ee5e"
                }
              }
            }
          ]
        },

Which, IIUC, sends mirrors all the traffic from the route. If weights can’t be combined with mirroring, we should emit a status condition to tell the user that. However, I think that we can look at the weights and automatically set a runtime_fraction for the mirror, so that this behaves the way it looks.

https://www.envoyproxy.io/docs/envoy/latest/api-v2/api/v2/route/route.proto#route-routeaction-requestmirrorpolicy

About this issue

  • Original URL
  • State: closed
  • Created 5 years ago
  • Comments: 17 (11 by maintainers)

Commits related to this issue

Most upvoted comments

Considering that the current behavior is to ignore users request to mirror only part of the traffic, it does not sound that bad to go with (1) and redefine weight as percentage, even when that is not what it was meant to be. It still likely achieves what the user wants, when property documented, and it avoids API deprecations which would be very confusing for the user as well.