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

rewrite annotation not working if multiple ingresses use the same backend #5140

Closed
1 task done
skoczko opened this issue Nov 9, 2023 · 3 comments
Closed
1 task done
Labels
bug Something isn't working

Comments

@skoczko
Copy link

skoczko commented Nov 9, 2023

Is there an existing issue for this?

  • I have searched the existing issues

Current Behavior

Given two ingresses that point to the same service but only one uses the rewrite annotation:

apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
  name: httpbin-1
  annotations:
    konghq.com/rewrite: /get
spec:
  ingressClassName: kong
  rules:
  - host: httpbin.example.com
    http:
      paths:
      - path: /rewrite
        pathType: Prefix
        backend:
          service:
            name: httpbin
            port:
              number: 8000
---
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
  name: httpbin-2
  annotations:
    konghq.com/strip-path: "true"
spec:
  ingressClassName: kong
  rules:
  - host: httpbin.example.com
    http:
      paths:
      - path: /regular
        pathType: Prefix
        backend:
          service:
            name: httpbin
            port:
              number: 8000

Requests both to httpbin.example.com/rewrite and httpbin.example.com/regular seem to randomly apply the same rewrite. This means that request to httpbin.example.com/rewrite will occasionally faily with 404 from httpbin and the request httpbin.example.com/regular will occasionally rewrite to /get while other times serve the httpbin root.

Expected Behavior

The rewrite is only and consistently applied for httpbin.example.com/rewrite

Steps To Reproduce

Use curl and request `httpbin.example.com/rewrite` and `httpbin.example.com/regular` 10 times each.

Kong Ingress Controller version

2.12.1

Kong version: 3.4

Kubernetes version

k version
Client Version: v1.28.3
Kustomize Version: v5.0.4-0.20230601165947-6ce0bf390ce3
Server Version: v1.25.11

Anything else?

No response

@skoczko skoczko added the bug Something isn't working label Nov 9, 2023
@skoczko
Copy link
Author

skoczko commented Nov 9, 2023

I belive this #5021 is a manifestation of the same bug.

@skoczko skoczko changed the title the rewrite annotation is not applied consistently rewrite annotation not working if multiple ingresses use the same backend Nov 10, 2023
@skoczko
Copy link
Author

skoczko commented Nov 10, 2023

Note that I have tested the same setup with two different httpbin deployments (httpbin1 and httpbin2) and the problem is gone so the issue is caused by using the same backend on two ingresses.

@mflendrich
Copy link
Contributor

Thank you @skoczko for your report and investigation. It is confirmed that KIC should apply the request-transformer plugin on the route and not on the service level. I'm going to close this issue as a duplicate and we'll track the fix in #5021, as it currently has more low-level details about the root cause that will be helpful for the resolution.

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