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

With Gateway API HttpRoute cannot use UrlRewrite and request-transformer plugin together #6390

Open
1 task done
zsedem opened this issue Aug 13, 2024 · 2 comments
Open
1 task done
Labels
bug Something isn't working
Milestone

Comments

@zsedem
Copy link

zsedem commented Aug 13, 2024

Is there an existing issue for this?

  • I have searched the existing issues

Current Behavior

Adding plugin with request-transformer type to an HTTPRoute with Rewrite will make one of the rules not take effect.
Either

  • The Additional header in the below example is not added.
  • The rewrite in the url for the upstream is not done.
---
apiVersion: configuration.konghq.com/v1
kind: KongPlugin
metadata:
  name: for-testing-header-transform
  namespace: rewrite-test
plugin: request-transformer
config:
  add:
    headers:
    - X-for-testing:ForTesting

---
apiVersion: gateway.networking.k8s.io/v1
kind: HTTPRoute
metadata:
  name: httpbin-post
  namespace: rewrite-test
  annotations:
    konghq.com/plugins: "for-testing-header-transform"
spec:
  parentRefs:
    - group: gateway.networking.k8s.io
      kind: Gateway
      name: rewrite-test
  rules:
    - matches:
      - path:
          type: Exact
          value: /post-rewrite
      filters:
      - type: URLRewrite
        urlRewrite:
          path:
            type: ReplaceFullPath
            replaceFullPath: /post

      backendRefs:
        - name: httpbin
          kind: Service
          port: 8000

Expected Behavior

Have the route both the additional header applied to it and the urlrewrite rule

Steps To Reproduce

I reproduced it in KinD, with the above config and everything left on default

Kong Ingress Controller version

2.3.0

Kubernetes version

kubectl version -o json
{
  "clientVersion": {
    "major": "1",
    "minor": "30",
    "gitVersion": "v1.30.2",
    "gitCommit": "39683505b630ff2121012f3c5b16215a1449d5ed",
    "gitTreeState": "archive",
    "buildDate": "1980-01-01T00:00:00Z",
    "goVersion": "go1.22.5",
    "compiler": "gc",
    "platform": "linux/amd64"
  },
  "kustomizeVersion": "v5.0.4-0.20230601165947-6ce0bf390ce3",
  "serverVersion": {
    "major": "1",
    "minor": "30",
    "gitVersion": "v1.30.0",
    "gitCommit": "7c48c2bd72b9bf5c44d21d7338cc7bea77d0ad2a",
    "gitTreeState": "clean",
    "buildDate": "2024-05-13T22:00:36Z",
    "goVersion": "go1.22.2",
    "compiler": "gc",
    "platform": "linux/amd64"
  }
}

Anything else?

In the proposed solution for the support of UrlRewrite here: #5853
They mention using a Kong request-transformer plugin, is it possible that because of this, we cannot use UrlRewrite and request-transformer plugin together?

@zsedem zsedem added the bug Something isn't working label Aug 13, 2024
@czeslavo
Copy link
Contributor

Hey @zsedem, thanks for the report. The short answer is: yes, this is an unexpected implicit limitation - we cannot create multiple instances of request-transformer Plugin associated with a single Kong Route.

I agree it's a bug and we should solve it either by:

  • making sure such configuration is not allowed, e.g. rejecting it in the validating webhook
  • trying to build the request-transformer configuration by merging the configuration generated by filters and the config provided by a user in a plugin (perhaps making the user's config higher priority in case of an overlap).

I'm adding this issue preliminary to 3.4 milestone and we will discuss how this should be fixed.

@czeslavo czeslavo added this to the KIC v3.4.x milestone Aug 29, 2024
@zsedem
Copy link
Author

zsedem commented Aug 29, 2024

For the time being, a reasonable workaround is creating a custom plugin, which does the request transformation.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants