Skip to content

filter_metadata is always empty when working with direct_response #17166

Closed

Description

@alex-lx

Title: filter_metadata would be empty when working with direct_response

Description:

Using the following config file

static_resources:
  clusters:
  - name: nginx
    connect_timeout: "10s"
    dns_lookup_family: V4_ONLY
    load_assignment:
      cluster_name: nginx
      endpoints:
      - lb_endpoints:
        - endpoint:
            address:
              socket_address:
                address: 127.0.0.1
                port_value: 8080

  listeners:
  - name: listener_0
    address:
      socket_address:
        address: 0.0.0.0
        port_value: 10000
    filter_chains:
    - filters:
      - name: envoy.filters.network.http_connection_manager
        typed_config:
          "@type": type.googleapis.com/envoy.extensions.filters.network.http_connection_manager.v3.HttpConnectionManager
          stat_prefix: ingress_http
          access_log:
          - name: envoy.access_loggers.stdout
            typed_config:
              "@type": type.googleapis.com/envoy.extensions.access_loggers.stream.v3.StdoutAccessLog
          http_filters:
          - name: envoy.filters.http.lua
            typed_config:
              '@type': type.googleapis.com/envoy.extensions.filters.http.lua.v3.Lua
              inline_code: |
                function envoy_on_request(request_handle)
                  request_handle:logInfo(string.format('foo=%s', request_handle:metadata():get('foo') or nil))
                end

                function envoy_on_response(response_handle)
                end

          - name: envoy.filters.http.router
          route_config:
            name: local_route
            virtual_hosts:
            - name: local_service
              domains: [ "*" ]
              routes:
              - name: r1
                metadata:
                  filter_metadata:
                    envoy.filters.http.lua:
                      foo: bar
                match:
                  prefix: '/'
#                route:
#                  cluster: "nginx"
                direct_response:
                  status: 200
                  body:
                    inline_string: "hello"

It's expected envoy would print log "foo=bar", but got "foo=nil" in fact.
If uncomment the route part and comment the direct_response part, will get "foo=bar" as expected.

Repro steps:
Our OS is MacOS 10.14.6 and envoy version is 98c1c9e/1.18.3/clean-getenvoy-b76c773-envoy/RELEASE/BoringSSL.

see the description for reproduce steps.

Admin and Stats Output:

Include the admin output for the following endpoints: /stats,
/clusters, /routes, /server_info. For more information, refer to the
admin endpoint documentation.

Note: If there are privacy concerns, sanitize the data prior to
sharing.

Config:

Include the config used to configure Envoy.

Logs:

Include the access logs and the Envoy logs.

Note: If there are privacy concerns, sanitize the data prior to
sharing.

Call Stack:

If the Envoy binary is crashing, a call stack is required.
Please refer to the Bazel Stack trace documentation.

Activity

  1. added
    triage
    on Jun 28, 2021
  2. changed the title [-]filter_metadata would be empty when working with direct_response[/-] [+]filter_metadata is always empty when working with direct_response[/+] on Jun 30, 2021
  3. added and removed
    triage
    on Jul 6, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions