emissary-ingress / emissary

open source Kubernetes-native API gateway for microservices built on the Envoy Proxy
https://www.getambassador.io
Apache License 2.0
4.36k stars 684 forks source link

generic_key is not attaching the correct key to the label/descriptor #4431

Open basimons opened 2 years ago

basimons commented 2 years ago

Describe the bug The generic_key label in emissary-ingress is not attaching the correct key as a descriptor.

According to the docs you would expect: image But when I apply this mapping:

apiVersion: getambassador.io/v3alpha1  
kind: Mapping  
metadata:  
  name: quote-backend  
  namespace: localservices  
  labels:  
    maps-to-host-label: main-host  
spec:  
  ambassador_id: ["ambassador-3"]  
  hostname: "*"  
  prefix: /backend/  
  service: quote  
  timeout_ms: 29000  
  labels:  
    ambassador:  
      - default_label: #apply to all mappings  
        - remote_address:  
            key: remote_address  
      - group_label_1:  
        - generic_key:  
            key: testKey  
            value: testValue  
        - request_headers:  
            header_name: Authorization  
            key: identifier

And I look at the logs of my rate limiter: image You can see that it is getting (generic_key, testValue), you would expect: (testKey, testValue). The request_headers mapping is working as expected.

To Reproduce Steps to reproduce the behavior:

  1. Install emissary
  2. Add the quote service the same as in the tutorial
  3. Add the mapping as shown above (maybe without the ambassador-id and remove the namespace)
  4. Add your RateLimiter of choice (I used the rate limit of Lyft) to see the output of the keys.

Expected behavior I'd expect (testKey, testValue).

Versions (please complete the following information):

Additional context For me this fortunately is not a big issue, as I only wanted to have 1 generic key anyway, but I'd imagine that this can be a very annoying bug if you want multiple generic keys.

basimons commented 2 years ago

I figured out yesterday that if you create this mapping inline, by using an annotation it does work as expected.