apache / apisix-ingress-controller

APISIX Ingress Controller for Kubernetes
https://apisix.apache.org/
Apache License 2.0
1k stars 342 forks source link

bug: Valid ApisixPluginConfig fails when being applied to apisix instance #2013

Closed dagvl closed 9 months ago

dagvl commented 11 months ago

Current Behavior

given this yaml:

---
apiVersion: apisix.apache.org/v2
kind: ApisixPluginConfig
metadata:
  name: default
  namespace: namespace
spec:
  plugins:
  - name: real-ip
    enable: false
    config:
      source: http_x_forwarded_for

when it is applied with kubectl, it is accepted:

❯ k apply -f ../apisix/resources/plugins.yaml
apisixpluginconfig.apisix.apache.org/default created

However, the ingress-controller reports an error when trying to apply it to apisix:

apisix/apisix_plugin_config.go:282  sync ApisixPluginConfig failed, will retry  {"object": {"Type":1,"Object":{"Key":"eu-north-1-dev-workflow-vimond/default","OldObject":null,"GroupVersion":"apisix.apache.org/v2"},"OldObject":null,"Tombstone":null}, "error": "1 error occurred:\n\t* unexpected status code 400; error message: {\"error_msg\":\"invalid configuration: additional properties forbidden, found name\"}\n\n\n"}

Logs from apisix:

10.121.59.47 - - [18/Oct/2023:22:17:44 +0000] apisix-admin.ingress-apisix.svc.cluster.local:9180 "PUT /apisix/admin/plugin_configs/76333208 HTTP/1.1" 400 94 0.000 "-" "Go-http-client/1.1" - - - "http://apisix-admin.ingress-apisix.svc.cluster.local:9180"

The exact same plugin block works fine when put directly in an ApisixRoute

Expected Behavior

Expect the plugin_config to be created without error

Error Logs

ingress-controller

apisix/apisix_plugin_config.go:282  sync ApisixPluginConfig failed, will retry  {"object": {"Type":1,"Object":{"Key":"eu-north-1-dev-workflow-vimond/default","OldObject":null,"GroupVersion":"apisix.apache.org/v2"},"OldObject":null,"Tombstone":null}, "error": "1 error occurred:\n\t* unexpected status code 400; error message: {\"error_msg\":\"invalid configuration: additional properties forbidden, found name\"}\n\n\n"}

apisix

10.121.59.47 - - [18/Oct/2023:22:17:44 +0000] apisix-admin.ingress-apisix.svc.cluster.local:9180 "PUT /apisix/admin/plugin_configs/76333208 HTTP/1.1" 400 94 0.000 "-" "Go-http-client/1.1" - - - "http://apisix-admin.ingress-apisix.svc.cluster.local:9180"

Steps to Reproduce

Install apisix with chart version 1.7.1. Make sure ingress-controller is enabled:

ingress-controller:
  enabled: true

k apply -f file.yaml where file.yaml is:

---
apiVersion: apisix.apache.org/v2
kind: ApisixPluginConfig
metadata:
  name: default
  namespace: default
spec:
  plugins:
  - name: real-ip
    enable: false
    config:
      source: http_x_forwarded_for

Environment

indrekj commented 11 months ago

Should be fixed here https://github.com/apache/apisix/pull/10315 but it is not released. We could also really use this fix.

jjdiazgarcia commented 10 months ago

@indrekj The error comes from apisix-ingress-controller but you said that error will be fixed in apisix (instead of apisix-ingress-controller). Is it fine? Or should it be fixed in apisix-ingress-controller since the error appears in apisix-ingress-controller?

indrekj commented 10 months ago

I'm currently using controller v1.7.1 and apisix docker image dev, and don't have this problem anymore.

jjdiazgarcia commented 10 months ago

@indrekj I have tried using latest docker image released some hours ago (3.7.0) and issue has gone so it has been fixed in the new released.