Add request mutation fields (authority, headers) to HTTPMirrorPolicy#3705
Add request mutation fields (authority, headers) to HTTPMirrorPolicy#3705aburan28 wants to merge 3 commits into
Conversation
|
🤔 🐛 You appear to be fixing a bug in Go code, yet your PR doesn't include updates to any test files. Did you forget to add a test? Courtesy of your friendly test nag. |
|
😊 Welcome @aburan28! This is either your first contribution to the Istio api repo, or it's been You can learn more about the Istio working groups, Code of Conduct, and contribution guidelines Thanks for contributing! Courtesy of your friendly welcome wagon. |
|
Hi @aburan28. Thanks for your PR. I'm waiting for a istio member to verify that this patch is reasonable to test. If it is, they should reply with Regular contributors should join the org to skip this step. Once the patch is verified, the new status will be reflected by the I understand the commands that are listed here. DetailsInstructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository. |
Expose Envoy's RequestMirrorPolicy.host_rewrite_literal and
request_headers_mutations on VirtualService HTTPMirrorPolicy via two
new fields:
authority: rewrites the Host (:authority) header on the mirrored
request. When set, Envoy implicitly disables the default "-shadow"
suffix that it would otherwise append to the Host header.
headers: header manipulation rules applied to the mirrored request,
reusing the existing Headers / HeaderOperations message. Only the
`request` side is honored; `response` mutations have no effect
since the mirrored response is discarded.
These let operators retarget mirror traffic at endpoints that perform
vhost-based routing, and inject/strip headers on shadow traffic (e.g.
adding "x-shadow: true" or removing internal-only headers) without
needing an EnvoyFilter.
Note: regenerated networking/v1alpha3/virtual_service.pb.go via
`buf generate` and patched kubernetes/customresourcedefinitions.gen.yaml
manually for the three VirtualService CRD versions. Reviewers should
re-run a full `make gen` to refresh doc and alias artifacts.
Signed-off-by: Adam Buran <aburan28@gmail.com>
b203531 to
45bbf7e
Compare
Signed-off-by: Adam Buran <aburan28@gmail.com>
Signed-off-by: Adam Buran <aburan28@gmail.com>
Summary
Expose Envoy's mirror-request mutation surface on
HTTPMirrorPolicyby adding two fields:authority— rewrites the Host (:authority) header on the mirrored request. Maps to Envoy'shost_rewrite_literal. When set, Envoy implicitly disables the default-shadowsuffix append.headers— request header manipulation rules applied to the mirrored request. Maps to Envoy'srequest_headers_mutations. This usesHeaders.HeaderOperationsdirectly so mirror config exposes only request mutations (set,add,remove) and does not expose a meaningless response-mutation branch.Motivation
Today, mirrored traffic always carries either the primary destination's Host header or that host with
-shadowappended (toggled by theDISABLE_SHADOW_HOST_SUFFIXpilot env). That's restrictive in several real-world cases:x-shadow: trueso downstream systems can ignore mirror requests in metrics/billing.Today users reach for
EnvoyFilterpatches for these — direct API support is cleaner and easier to validate.authoritymirrors the naming of the existingHTTPRewrite.authorityfield (which does the equivalent thing on the primary request), so the API stays internally consistent.Changes
networking/v1alpha3/virtual_service.proto: addedauthority(string, fieldnum 3) and request-onlyheaders(Headers.HeaderOperations, fieldnum 4) toHTTPMirrorPolicy.networking/v1alpha3/virtual_service.pb.gowithprotoc-gen-go v1.36.11.networking/v1alpha3/virtual_service.pb.htmlso API docs include the new fields.kubernetes/customresourcedefinitions.gen.yaml;mirrors[].headersnow exposes onlyset,add, andremovein all three VirtualService CRD versions.Notes for reviewers
The
v1/v1beta1alias files re-export thev1alpha3type via=and need no change. Deepcopy delegates toproto.Cloneand the JSON shim uses proto reflection, so both pick up the new fields automatically.A companion change in
istio/istiowires these throughTranslateRequestMirrorPolicy(including a smallHeaderOperations→ EnvoyHeaderMutationtranslator for the mirror case) and will be sent as a follow-up PR once this lands and a taggedistio.io/apiis available.Test plan
BUILD_WITH_CONTAINER=0 make gen-protobuf lintgo test ./...python3 scripts/validate_crds.py check_equal_schema --kinds VirtualService --versions v1,v1beta1,v1alpha3 --file kubernetes/customresourcedefinitions.gen.yamlscripts/breaking.sh mastergit diff --check/ok-to-testNote:
BUILD_WITH_CONTAINER=0 UPDATE_BRANCH=master make gen-checkcannot complete on this macOS host becauseclean.shusesshopt -s globstar, which is unsupported by the system Bash 3.2. The generation, lint, CRD schema, breaking, and Go test steps above were run directly.