Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ext_proc: allow override metadata without grpc_service #31544

Merged
merged 15 commits into from
Feb 27, 2024

test/ext_proc: integ test improvement to check upstream hdrs

6a28914
Select commit
Loading
Failed to load commit list.
Merged

ext_proc: allow override metadata without grpc_service #31544

test/ext_proc: integ test improvement to check upstream hdrs
6a28914
Select commit
Loading
Failed to load commit list.
CI (Envoy) / Mobile/Android tests skipped Feb 17, 2024 in 0s

Check was skipped

This check was not triggered in this CI run

Details

Request (pr/31544/main@6a28914)

sitano @sitano 6a28914 #31544 merge main@f301eeb

ext_proc: allow override metadata without grpc_service

Commit Message: ext_proc: allow override metadata without grpc_service

The patch introduces overrides.grpc_initial_metadata in ExtProcPerRoute.overrides that appends and overrides parent metadata:

  - match:
      ...
    route:
      ...
    typed_per_filter_config:
      envoy.filters.http.ext_proc:
        "@type": type.googleapis.com/envoy.extensions.filters.http.ext_proc.v3.ExtProcPerRoute
        overrides:
          grpc_initial_metadata:
            - key: "b"
              value: "c"
            - key: "c"
              value: "c"
http_filters:
- name: envoy.filters.http.ext_proc
typed_config:
  "@type": type.googleapis.com/envoy.extensions.filters.http.ext_proc.v3.ExternalProcessor
  grpc_service:
    envoy_grpc:
      cluster_name: ext-proc-proxy
    timeout: 60s
    initial_metadata:
      - key: "a"
        value: "a"
      - key: "b"
        value: "b"

that allows to have:

a: a
b: c
c: c

like the following:

[2024-01-09 16:40:23.241][1967519][debug][router] [source/common/router/router.cc:731] [Tags: "ConnectionId":"0","StreamId":"5894068517272876876"] router decoding headers:
':method', 'POST'
':path', '/envoy.service.ext_proc.v3.ExternalProcessor/Process'
':authority', 'ext-proc-proxy'
':scheme', 'http'
'te', 'trailers'
'content-type', 'application/grpc'
'a', 'a'
'b', 'c'
'c', 'c'
'x-envoy-internal', 'true'
'x-forwarded-for', '172...'

Additional Description: new ext_proc per route override of inherited grpc metadata without specifying grpc_service
Risk Level: low
Testing: Unit, Integration, Config
Docs Changes: will have to update https://www.envoyproxy.io/docs/envoy/latest/api-v3/extensions/filters/http/ext_proc/v3/ext_proc.proto#extensions-filters-http-ext-proc-v3-extprocperroute regarding repeated config.core.v3.HeaderValue grpc_initial_metadata = 7;.

// Additional metadata to include into streams initiated to the ext_proc gRPC
// service. This can be used for scenarios in which additional ad hoc
// authorization headers (e.g. x-foo-bar: baz-key) are to be injected or
// when a route needs to partially override inherited metadata.

Release Notes: see changlelogs/current.yaml
Platform Specific Features: -

Testing

$ bazel test //test/extensions/filters/http/ext_proc:config_test --config=clang --verbose_failures --test_arg="-l trace"
$ bazel test //test/extensions/filters/http/ext_proc:filter_test --config=clang --verbose_failures --test_arg="-l trace"
$ bazel test //test/extensions/filters/http/ext_proc:ext --config=clang --verbose_failures --test_arg=--gtest_filter='*/ExtProcIntegrationTest.PerRouteGrpcMetadata/*' --test_arg="-l trace"

Test infrastructure https://github.com/sitano/envoy/tree/ivan_api_502/examples/grpc-bridge:

t1$ cd ./server && go run
t2$ cd ./ext_proc && go run
t3$ envoy/bazel-bin/source/exe/envoy-static --config-path ./envoy-proxy.yaml --log-level debug --base-id 1
// t4$ envoy/bazel-bin/source/exe/envoy-static --config-path ./envoy-proxy.yaml --log-level debug --base-id 2
t5$ envoy/bazel-bin/source/exe/envoy-static --config-path ./envoy-proxy-ext_proc-2.yaml --log-level trace --base-id 3
$ CLIENT_PROXY=http://127.0.0.1:9911 ./client.py set key1 1
$ CLIENT_PROXY=http://127.0.0.1:9911 ./client.py set key2 1
$ CLIENT_PROXY=http://127.0.0.1:9911 ./client.py set key3 1
$ ss -tnp

Example

Environment

Request variables

Key Value
ref cfcc37514fe247000ae91c31c00929d492031cf9
sha 6a28914
pr 31544
base-sha f301eeb
actor sitano @sitano
message ext_proc: allow override metadata without grpc_service...
started 1708166462.349855
target-branch main
trusted false
Build image

Container image/s (as used in this CI run)

Key Value
default envoyproxy/envoy-build-ubuntu:0ca52447572ee105a4730da5e76fe47c9c5a7c64
mobile envoyproxy/envoy-build-ubuntu:mobile-0ca52447572ee105a4730da5e76fe47c9c5a7c64
Version

Envoy version (as used in this CI run)

Key Value
major 1
minor 30
patch 0
dev true