solo-io / gloo

The Feature-rich, Kubernetes-native, Next-Generation API Gateway Built on Envoy
https://docs.solo.io/
Apache License 2.0
4.08k stars 438 forks source link

inheritTransformation not working as expected #9126

Open edubonifs opened 8 months ago

edubonifs commented 8 months ago

Gloo Edge Product

Enterprise

Gloo Edge Version

1.15

Kubernetes Version

1.26

Describe the bug

Hi, one of our clients is using gloo portal, and he has the requirement to get an api-key from the query, not from a header directly, that's why they are applying this transformation:

apiVersion: gateway.solo.io/v1
kind: VirtualService
metadata:
  name: auth-tutorial
  namespace: gloo-system
  resourceVersion: "63818246"
  uid: 7f9acfb5-1f29-455a-aa31-e8af6d25e2b6
spec:
  virtualHost:
    domains:
    - api.test.devtest
    routes:
    - delegateAction:
        selector:
          labels:
            environments.portal.gloo.solo.io: default.gloo-system
      matchers:
      - prefix: /
      name: paymentplan-public-api.v1
      options:
        stagedTransformations:
          early:
            requestTransforms:
            - requestTransformation:
                transformationTemplate:
                  extractors:
                    apik:
                      header: :path
                      regex: (.*key=([^&]*).*)
                      subgroup: 2
                  headers:
                    Api-Key:
                      text: '{{ apik }}'

This transformation is working as expected, the problem comes with he transformation they have applied in the RouteTable, which is also stagedTransformation, early one. So they have early stagedTransformations both at early and regular stage.

According to our docs:

If a child attribute defines its own transformation, it overrides the configuration on its parent. However, if inheritTransformation is set to true on the stagedTransformations for a Route, it can inherit transformations from its parent as illustrated below.

apiVersion: gateway.solo.io/v1 kind: VirtualService metadata: name: auth-tutorial namespace: gloo-system spec: virtualHost: domains:

curl "http://af470994079bd42988df248a8a6e2903-178984659.us-east-1.elb.amazonaws.com/get?key=blahblah" -H "Host: api.test" -v 
{
  "args": {
    "key": "blahblah"
  }, 
  "headers": {
    "Accept": "*/*", 
    "Host": "api.test", 
    "Location": "loc", 
    "User-Agent": "curl/7.85.0", 
    "X-Envoy-Expected-Rq-Timeout-Ms": "15000"
  }, 
  "origin": "192.168.36.36", 
  "url": "http://api.test.devtest.animalfriends.co.uk/get?key=blahblah"
}

Expected Behavior

Both transformations should be applied

Steps to reproduce the bug

VirtualService:

Additional Environment Detail

No response

Additional Context

No response

github-actions[bot] commented 3 weeks ago

This issue has been marked as stale because of no activity in the last 180 days. It will be closed in the next 180 days unless it is tagged "no stalebot" or other activity occurs.