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: PluginConfigId is not assigned to the route in case upstreams used instead of the backends #1577

Closed
ikatlinsky opened this issue Jan 2, 2023 · 4 comments · Fixed by #1578 or #1594
Assignees
Labels
bug Something isn't working triage/accepted Indicates an issue or PR is ready to be actively worked on.

Comments

@ikatlinsky
Copy link
Contributor

Issue description

I am using the ingress controller to create the following apisix resources:

  • Plugin configs
  • Upstream
  • Route

The following definitions are used:

apiVersion: apisix.apache.org/v2
kind: ApisixUpstream
metadata:
  name: httpbin-upstream
  namespace: acl
spec:
  externalNodes:
  - type: Domain
    name: httpbin.org
  retries: 3
  timeout:
    connect: "3s"
    send: "2s"
    read: "3s"
  loadbalancer:
    type: roundrobin
  healthCheck:
    active:
      concurrency: 10
      host: httpbin.org
      type: http
      timeout: 2
      httpPath: /
      healthy:
        httpCodes:
          - 200
          - 302
        interval: "1s"
        successes: 3
      unhealthy:
        httpCodes:
          - 429
          - 404
          - 500
          - 501
          - 502
          - 503
          - 504
          - 505
        httpFailures: 5
        interval: "3s"
        tcpFailures: 2
        timeouts: 3
---
apiVersion: apisix.apache.org/v2
kind: ApisixPluginConfig
metadata:
  name: httpbin-plugins
  namespace: acl
spec:
  plugins:
  - name: proxy-rewrite
    enable: true
    config:
      regex_uri:
      - "^/httpbin/(.*)"
      - "/$1"
---
apiVersion: apisix.apache.org/v2
kind: ApisixRoute
metadata:
  name: httpbin-route
  namespace: acl
spec:
  http:
    - name: httpbin-route-rule
      match:
        hosts:
          - apisix.local.net
        paths:
          - /httpbin/*
        methods:
          - GET
      upstreams:
        - name: httpbin-upstream
      plugin_config_name: httpbin-plugins

As result my configuration is applied to the apisix, but plugin config is not assigned to the route.
My assumption that issue is because of the bug in the following file: apisix_route.go, more precisely the following fragment

if part.PluginConfigName != "" {
				route.PluginConfigId = id.GenID(apisixv1.ComposePluginConfigName(ar.Namespace, part.PluginConfigName))
			}

is only executed when len(backends) > 0 (function translateHTTPRouteV2).

I guess it should be applied both for case with backends and case with upstream, like mine.

Environment

  • your apisix-ingress-controller version (output of apisix-ingress-controller version --long): 1.6.0
  • your Kubernetes cluster version (output of kubectl version): 1.23.6

Minimal test code / Steps to reproduce

  1. Apply the definitions which are provided above
  2. Wait till definitions will be applied
  3. Check resulted configuration of the route

Actual result

{
  "uris": [
    "/httpbin/*"
  ],
  "name": "acl_httpbin-route_httpbin-route-rule",
  "desc": "Created by apisix-ingress-controller, DO NOT modify it manually",
  "methods": [
    "GET"
  ],
  "hosts": [
    "apisix.local.net"
  ],
  "upstream_id": "6f1d84e5",
  "labels": {
    "managed-by": "apisix-ingress-controller"
  },
  "status": 1
}

plugin_config_id is missed from the configuration

Error log

no error log, just incorrect behaviour

Expected result

plugin_config_id is properly assigned to the route

@ikatlinsky
Copy link
Contributor Author

@tao12345666333 created a PR that should fix the problem, described above - #1578, I hope that will help. Tell me if there are any issues or questions regarding the proposed changes.

@AlinsRan AlinsRan added bug Something isn't working triage/accepted Indicates an issue or PR is ready to be actively worked on. labels Jan 3, 2023
@tao12345666333
Copy link
Member

Thanks! I will add comments in #1578

@ikatlinsky ikatlinsky changed the title bug: PluginConfigId is not assign to the route in case upstreams used instead of the backends bug: PluginConfigId is not assigned to the route in case upstreams used instead of the backends Jan 9, 2023
@tao12345666333
Copy link
Member

It has been resolved. I will close this one, thanks

@renatomattos2912
Copy link

It has been resolved. I will close this one, thanks

Hello tao, im trying to update my controller to get this fix, but the latest image in docker repo for ingress controller is 1.6.0 and it is still not working for this bug here. It is planned to be in 1.6.1 or any future docker image for ingresso controller?

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
None yet
4 participants