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

bug: Can't define multiple k8s ingress definitions with pathType: Prefix pointing to single service when using combined mode #2276

Open
boscard opened this issue Aug 5, 2024 · 3 comments

Comments

@boscard
Copy link

boscard commented Aug 5, 2024

Current Behavior

Defining two ingress definitions pointing to single service with pathType prefix and different paths will cause

error   adapter/etcd.go:141     failed to create object, ignore it{error 26 0  rpc error: code = InvalidArgument desc = etcdserver: duplicate key given in txn request} {revision 11 2939  <nil>} {key 15 0 /apisix/upstreams/5ce57b8e <nil>}

Where in traditional mode everything works perfectly fine.

Expected Behavior

In combine mode there should also be possible to define multiple ingress definitions pointing to single service, where path is different for ingress definitions.

Error Logs

2024-08-05T22:18:01+08:00       info    adapter/etcd.go:147     created object{revision 11 2938  <nil>} {key 15 0 /apisix/upstreams/5ce57b8e <nil>}
2024-08-05T22:18:01+08:00       info    adapter/etcd.go:147     created object{revision 11 2939  <nil>} {key 15 0 /apisix/routes/bcb4f1ad <nil>}
2024-08-05T22:18:01+08:00       error   adapter/etcd.go:141     failed to create object, ignore it{error 26 0  rpc error: code = InvalidArgument desc = etcdserver: duplicate key given in txn request} {revision 11 2939  <nil>} {key 15 0 /apisix/upstreams/5ce57b8e <nil>}
2024-08-05T22:18:01+08:00       info    adapter/etcd.go:147     created object{revision 11 2940  <nil>} {key 15 0 /apisix/routes/59ac5ae4 <nil>}

Steps to Reproduce

  1. Install APISIX Ingress controller in combined mode
  2. Deploy httpbin for example using this specs:
---
apiVersion: apps/v1
kind: Deployment
metadata:
  name: httpbin-deployment
  namespace: default
spec:
  replicas: 1
  selector:
    matchLabels:
      app: httpbin-deployment
  template:
    metadata:
      labels:
        app: httpbin-deployment
    spec:
      containers:
        - name: httpbin-deployment
          image: kennethreitz/httpbin:latest
          imagePullPolicy: IfNotPresent
          ports:
            - name: http
              containerPort: 80
              protocol: TCP
          resources: {}
          livenessProbe:
            tcpSocket:
              port: 80
            initialDelaySeconds: 2
            timeoutSeconds: 2
            periodSeconds: 5
            successThreshold: 1
            failureThreshold: 3
          readinessProbe:
            tcpSocket:
              port: 80
            initialDelaySeconds: 2
            timeoutSeconds: 2
            periodSeconds: 5
            successThreshold: 1
            failureThreshold: 3
---
apiVersion: v1
kind: Service
metadata:
  name: httpbin
  namespace: default
spec:
  selector:
    app: httpbin-deployment
  ports:
  - name: http
    port: 80
    protocol: TCP
    targetPort: 80
  type: ClusterIP
  1. Deploy 2 Ingress definitions
---
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
  name: api1
  namespace: default
spec:
  ingressClassName: apisix
  rules:
    - http:
        paths:
          - backend:
              service:
                name: httpbin
                port:
                  number: 80
            path: /api1/api1
            pathType: Prefix
---
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
  name: api2
  namespace: default
spec:
  ingressClassName: apisix
  rules:
    - http:
        paths:
          - backend:
              service:
                name: httpbin
                port:
                  number: 80
            path: /api2/api2
            pathType: Prefix

Environment

  • APISIX Ingress controller version: v1.7.0, v1.7.1, v1.8.0, v1.8.1, v1.8.2
  • Kubernetes cluster version: v1.29.2
@rknightion
Copy link

rknightion commented Aug 14, 2024

We're also seeing this although we seem to get it even when not using ingress but rather simple httproute CRs

With this:

apiVersion: apisix.apache.org/v2
kind: ApisixRoute
metadata:
  name: route-test
  namespace: fek-test
spec:
  http:
    - backends:
        - resolveGranularity: service
          serviceName: data-capture
          servicePort: 8080
          weight: 100
      match:
        hosts:
          - test.test.XXX.XXX.XXX
        paths:
          - /api/data-capture/forms/*
          - /api/data-capture/profiles
          - /api/data-capture/v1/fan/*
      name: route-data-capture-public
      plugins:
        - config:
            headers:
              X-Tenant-Id: XXX
            regex_uri:
              - ^/api/data-capture(.*)$
              - $1
          enable: true
          name: proxy-rewrite

We get

2024-08-15T03:05:00+08:00	error	adapter/etcd.go:141	failed to create object, ignore it{error 26 0  rpc error: code = InvalidArgument desc = etcdserver: duplicate key given in txn request} {revision 11 93  <nil>} {key 15 0 /apisix/routes/3b8426dd <nil>}

Making me think it happens whenever multiple paths talk to the same backend. This doesn't happen with the etcd version of apisix + ingress controller

@rknightion
Copy link

This looks similar to #2071 in a way.

@boscard have you used etcdctl to see whats showing in the ingress controller etcd-adapter for your troublesome route?

@boscard
Copy link
Author

boscard commented Aug 20, 2024

@rknightion no, I was not trying with etcdctl. If you can point me to some docs/readme how can I do it I will try.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants