envoyproxy / envoy

Cloud-native high-performance edge/middle/service proxy
https://www.envoyproxy.io
Apache License 2.0
24.32k stars 4.7k forks source link

Does RequestMirrorPolicy support xDS? #34916

Open whutwhu opened 3 weeks ago

whutwhu commented 3 weeks ago

We rely on xDS to dynamically fetch resources from our control plane, following the flow: vhds -> cds -> eds. This means the client fetches vhds first on demand, then cds, and finally eds. When supporting request mirroring, is it possible to also fetch the mirrored cluster via xDS?

For example, we configure the request_mirror_policies in the vhds in the control plane, as shown below. The "backendCluster" can be fetched from CDS, but the mirrored cluster "darkBackendCluster" cannot be fetched, resulting in the error message: "shadow cluster 'darkBackendCluster' does not exist."

According to the manual, the cluster specified in request_mirror_policies must exist in the cluster manager configuration. Does this mean that request_mirror_policies cannot support xDS?

Here is our vhds configuration from the control plane, with request_mirror_policies included:

vhds: { "name": "global/backService", "version": "227659762142", "resource": { "@type": "type.googleapis.com/envoy.config.route.v3.VirtualHost", "name": "global/backendService", "domains": [ "backendService" ], "requestMirrorPolicies": [ { "cluster": "darkBackendCluster" } ] "routes": [ { "match": { "prefix": "/" }, "route": { "cluster": "backendCluster", } } ] } }

mattklein123 commented 3 weeks ago

See the validate_clusters option. It should allow it to load and fail gracefully at runtime if the cluster doesn't exist.

// An optional boolean that specifies whether the clusters that the route
  // table refers to will be validated by the cluster manager. If set to true
  // and a route refers to a non-existent cluster, the route table will not
  // load. If set to false and a route refers to a non-existent cluster, the
  // route table will load and the router filter will return a 404 if the route
  // is selected at runtime. This setting defaults to true if the route table
  // is statically defined via the :ref:`route_config
  // <envoy_v3_api_field_extensions.filters.network.http_connection_manager.v3.HttpConnectionManager.route_config>`
  // option. This setting default to false if the route table is loaded dynamically via the
  // :ref:`rds
  // <envoy_v3_api_field_extensions.filters.network.http_connection_manager.v3.HttpConnectionManager.rds>`
  // option. Users may wish to override the default behavior in certain cases (for example when
  // using CDS with a static route table).
  google.protobuf.BoolValue validate_clusters = 7;