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: ApisixRoute backendPoint duplicate #732

Closed
zlhgo opened this issue Nov 2, 2021 · 2 comments
Closed

bug: ApisixRoute backendPoint duplicate #732

zlhgo opened this issue Nov 2, 2021 · 2 comments
Labels
bug Something isn't working triage/accepted Indicates an issue or PR is ready to be actively worked on.
Milestone

Comments

@zlhgo
Copy link
Contributor

zlhgo commented Nov 2, 2021

Issue description

pkg/kube/translation/apisix_route.go:258
ApisixRoute backendPoint duplicates

Environment

  • your apisix-ingress-controller version (output of apisix-ingress-controller version --long);
→ ./apisix-ingress-controller version --long                                                          
Version: 1.3.0
Git SHA: 65f7c88
Go Version: go1.17.2
Building OS/Arch: linux/amd64
Running OS/Arch: linux/amd64
  • your Kubernetes cluster version (output of kubectl version);
→ kubectl version                                                                                     
Client Version: version.Info{Major:"1", Minor:"21", GitVersion:"v1.21.2", GitCommit:"092fbfbf53427de67cac1e9fa54aaa09a28371d7", GitTreeState:"clean", BuildDate:"2021-06-16T12:59:11Z", GoVersion:"go1.16.5", Compiler:"gc", Platform:"linux/amd64"}
Server Version: version.Info{Major:"1", Minor:"20", GitVersion:"v1.20.2", GitCommit:"faecb196815e248d3ecfb03c680a4507229c2a56", GitTreeState:"clean", BuildDate:"2021-01-13T13:20:00Z", GoVersion:"go1.15.5", Compiler:"gc", Platform:"linux/amd64"}
  • if you run apisix-ingress-controller in Bare-metal environment, also show your OS version (uname -a).
→ uname -a                                                                                            
Linux zlh-PC 5.10.60-amd64-desktop #1 SMP Thu Aug 26 18:24:56 CST 2021 x86_64 GNU/Linux

Minimal test code / Steps to reproduce the issue

  1. ApisixRoute config
apiVersion: apisix.apache.org/v2beta1
kind: ApisixRoute
metadata:
  name: flask-demo
spec:
  http:
  - name: http-8000
    match:
      hosts:
      - flask-demo.local.cn
      paths:
      - /*
    backends:
      - serviceName: flask-demo
        servicePort: 8000
        weight: 100
      - serviceName: flask-demo-group-a
        servicePort: 8000
        weight: 50
      - serviceName: flask-demo-group-b
        servicePort: 8000
        weight: 50

What's the actual result? (including assertion message & call stack if applicable)

image

What's the expected result?

image

Patch

diff --git a/pkg/kube/translation/apisix_route.go b/pkg/kube/translation/apisix_route.go
index 9ffee9f..928a7db 100644
--- a/pkg/kube/translation/apisix_route.go
+++ b/pkg/kube/translation/apisix_route.go
@@ -254,8 +254,8 @@ func (t *translator) translateHTTPRouteV2beta1(ctx *TranslateContext, ar *config
                                weight = *backend.Weight
                        }
                        backendPoints := make([]*configv2alpha1.ApisixRouteHTTPBackend, 0)
-                       for _, b := range backends {
-                               backendPoints = append(backendPoints, &b)
+                       for i, _ := range backends {
+                               backendPoints = append(backendPoints, &backends[i])
                        }
                        plugin, err := t.translateTrafficSplitPlugin(ctx, ar.Namespace, weight, backendPoints)
                        if err != nil {
@tao12345666333 tao12345666333 added triage/accepted Indicates an issue or PR is ready to be actively worked on. bug Something isn't working labels Nov 2, 2021
@tao12345666333
Copy link
Member

Thanks! Can you open a PR fix this?

@tao12345666333 tao12345666333 added this to the 1.4.0 milestone Nov 2, 2021
@tao12345666333 tao12345666333 added this to To do in v1.4 Planning via automation Nov 2, 2021
@tao12345666333
Copy link
Member

#734 has been merged. I will close this one.

v1.4 Planning automation moved this from To do to Done Nov 24, 2021
Sindweller pushed a commit to Sindweller/apisix-ingress-controller that referenced this issue Nov 25, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working triage/accepted Indicates an issue or PR is ready to be actively worked on.
Projects
No open projects
Development

No branches or pull requests

2 participants