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

Release 0.34.0 Break Regex Paths #5890

Closed
jzhang046 opened this issue Jul 14, 2020 · 1 comment · Fixed by #5896
Closed

Release 0.34.0 Break Regex Paths #5890

jzhang046 opened this issue Jul 14, 2020 · 1 comment · Fixed by #5896
Labels
kind/bug Categorizes issue or PR as related to a bug.

Comments

@jzhang046
Copy link

NGINX Ingress controller version: 0.34.0

Kubernetes version (use kubectl version): v1.9.6

What happened:
With #5691 merged and released in 0.34.0, following issues have occurred:

  • The behaviour is not consistent with the documentation, in which it says that

If the use-regex OR rewrite-target annotation is used on any Ingress for a given host, then the case insensitive regular expression location modifier will be enforced on ALL paths for a given host regardless of what Ingress they are defined on.

  • Regex path does not work with only nginx.ingress.kubernetes.io/rewrite-target annotation. Seems like additional nginx.ingress.kubernetes.io/use-regex annotation has to be applied in order for regex path to work.
  • @zrdaley has made a great example of why it was necessary to apply regex to all locations: use-regex annotation should be applied to only one Location #5691 (comment). Directly upgrading to 0.34.0 from 0.33.0 will make ingress resources behave differently.

What you expected to happen:
Keep the existing behaviour until 0.33.0 and apply regex to all locations

How to reproduce it:

  • Install the ingress controller
kubectl apply -f https://raw.githubusercontent.com/kubernetes/ingress-nginx/master/deploy/static/provider/baremetal/deploy.yaml
  • Install an application that will act as default backend (is just an echo app)
kubectl apply -f https://raw.githubusercontent.com/kubernetes/ingress-nginx/master/docs/examples/http-svc.yaml
  • Create an ingress (please add any additional annotation required)
echo "
  apiVersion: networking.k8s.io/v1beta1
  kind: Ingress
  metadata:
    name: foo-bar
  spec:
    rules:
    - host: foo.bar
      http:
        paths:
        - backend:
            serviceName: http-svc
            servicePort: 80
          path: /
" | kubectl apply -f -

echo "
  apiVersion: networking.k8s.io/v1beta1
  kind: Ingress
  metadata:
    name: foo-bar-rewrite
    annotations: 
      nginx.ingress.kubernetes.io/rewrite-target: /\$1
  spec:
    rules:
    - host: foo.bar
      http:
        paths:
        - backend:
            serviceName: http-svc
            servicePort: 80
          path: /foo/bar/(.+)
" | kubectl apply -f -
  • make a request
POD_NAME=$(kubectl get pods -n ingress-nginx -l app.kubernetes.io/name=ingress-nginx -o NAME)
kubectl exec -it -n ingress-nginx $POD_NAME -- curl -H 'Host: foo.bar' localhost/foo/bar/123
  • expected result
Request Information:
        client_address=172.18.0.5
        method=GET
        real path=/123
        query=
        request_version=1.1
        request_scheme=http
        request_uri=http://foo.bar:8080/123
  • actual result
Request Information:
        client_address=172.18.0.5
        method=GET
        real path=/foo/bar/123
        query=
        request_version=1.1
        request_scheme=http
        request_uri=http://foo.bar:8080/foo/bar/123
  • temporary fix to get expected result
echo "
  apiVersion: networking.k8s.io/v1beta1
  kind: Ingress
  metadata:
    name: foo-bar-rewrite
    annotations: 
      nginx.ingress.kubernetes.io/use-regex: \"true\"
      nginx.ingress.kubernetes.io/rewrite-target: /\$1
  spec:
    rules:
    - host: foo.bar
      http:
        paths:
        - backend:
            serviceName: http-svc
            servicePort: 80
          path: /foo/bar/(.+)
" | kubectl apply -f -

Anything else we need to know: N. A.

/kind bug

@aledbf
Copy link
Member

aledbf commented Jul 15, 2020

@jzhang046 we just release 0.34.1 reverting that change. I am adding new e2e tests to avoid this problem in the future

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/bug Categorizes issue or PR as related to a bug.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants