apisix-ingress-controller
apisix-ingress-controller copied to clipboard
bug: update apisixroute.yaml spec.http.name from a981a76 to api,Sometimes two routes are generated
Issue description
update apisixroute.yaml spec.http.name from a981a76 to api,Sometimes two routes are generated
kubectl get ar -A |grep screensaver
,only one data
However, there are two data on dashboard, apisix-Ingress-Controller's log is missing, so I can't find the problem now .
Etcd has some of the same data,Id and name are different routes/5341fe35 {"status":1,"uris":["/business-screensaver/"],"hosts":[""],"upstream_id":"e0a2d230","desc":"Created by apisix-ingress-controller, DO NOT modify it manually","update_time":1650358919,"create_time":1650358919,"priority":0,"id":"5341fe35","name":"*-business-screensaver_api","labels":{"managed-by":"apisix-ingress-controller"},"plugins":{"proxy-rewrite":{"regex_uri":["***business-screensaver/(.)","/$1"]}}}
routes/31f041fe {"status":1,"uris":["/business-screensaver/"],"hosts":["***"],"upstream_id":"e0a2d230","desc":"Created by apisix-ingress-controller, DO NOT modify it manually","update_time":1649379005,"create_time":1649379005,"priority":0,"id":"31f041fe","name":"*****business-screensaver_a981a76","labels":{"managed-by":"apisix-ingress-controller"},"plugins":{"proxy-rewrite":{"regex_uri":["^***business-screensaver/(.)","/$1"]}}}
Currently, only this route is found to be faulty. All other routes change spec.http.name to API, and only change the original data a981a76 does not generate a new route entry 。
It is not clear when apisix-Controller creates a new route entry, and when does it modify the original data
At present, only the phenomenon can be seen, but it is not clear how to troubleshoot and reappear,Ask for Help
Environment
- your apisix-ingress-controller version (output of apisix-ingress-controller version --long):
- your Kubernetes cluster version (output of kubectl version):
- if you run apisix-ingress-controller in Bare-metal environment, also show your OS version (uname -a):
Minimal test code / Steps to reproduce
{{- if .Values.apisixroute.enabled -}}
apiVersion: apisix.apache.org/v2beta3
kind: ApisixRoute
metadata:
name: {{ include "test.fullname" . }}
spec:
http:
- name: a981a76
match:
hosts:
- "{{ .Values.apisixroute.host }}"
paths:
- "{{ .Values.apisixroute.path }}*"
plugins:
- name: proxy-rewrite
enable: true
config:
regex_uri: ["^{{ .Values.apisixroute.path }}(.*)", "/$1"]
backends:
- serviceName: "{{ include "test.fullname" . }}"
servicePort: 80
{{- end -}}
{{- if .Values.apisixroute.enabled -}}
apiVersion: apisix.apache.org/v2beta3
kind: ApisixRoute
metadata:
name: {{ include "test.fullname" . }}
spec:
http:
- name: api
match:
hosts:
- "{{ .Values.apisixroute.host }}"
paths:
- "{{ .Values.apisixroute.path }}*"
plugins:
- name: proxy-rewrite
enable: true
config:
regex_uri: ["^{{ .Values.apisixroute.path }}(.*)", "/$1"]
backends:
- serviceName: "{{ include "test.fullname" . }}"
servicePort: 80
{{- end -}}
Render yamL1 template with helm changed to render YamL2 template with helm
Actual result
The dashboard produces two identical servername and path
Etcd has some of the same data,Id and name are different routes/5341fe35 {"status":1,"uris":["/business-screensaver/"],"hosts":[""],"upstream_id":"e0a2d230","desc":"Created by apisix-ingress-controller, DO NOT modify it manually","update_time":1650358919,"create_time":1650358919,"priority":0,"id":"5341fe35","name":"*-business-screensaver_api","labels":{"managed-by":"apisix-ingress-controller"},"plugins":{"proxy-rewrite":{"regex_uri":["***business-screensaver/(.)","/$1"]}}}
routes/31f041fe {"status":1,"uris":["/business-screensaver/"],"hosts":["***"],"upstream_id":"e0a2d230","desc":"Created by apisix-ingress-controller, DO NOT modify it manually","update_time":1649379005,"create_time":1649379005,"priority":0,"id":"31f041fe","name":"*****business-screensaver_a981a76","labels":{"managed-by":"apisix-ingress-controller"},"plugins":{"proxy-rewrite":{"regex_uri":["^***business-screensaver/(.)","/$1"]}}}
Error log
There is no error log [GIN] 2022/04/27 - 20:44:33 | 200 | 27.103µs | 169.254.1.1 | GET "/healthz" [GIN] 2022/04/27 - 20:44:43 | 200 | 30.804µs | 169.254.1.1 | GET "/healthz" [GIN] 2022/04/27 - 20:44:43 | 200 | 26.288µs | 169.254.1.1 | GET "/healthz" [GIN] 2022/04/27 - 20:44:53 | 200 | 27.1µs | 169.254.1.1 | GET "/healthz" [GIN] 2022/04/27 - 20:44:53 | 200 | 27.51µs | 169.254.1.1 | GET "/healthz" [GIN] 2022/04/27 - 20:45:03 | 200 | 29.087µs | 169.254.1.1 | GET "/healthz" [GIN] 2022/04/27 - 20:45:03 | 200 | 24.202µs | 169.254.1.1 | GET "/healthz" [GIN] 2022/04/27 - 20:45:13 | 200 | 24.406µs | 169.254.1.1 | GET "/healthz" [GIN] 2022/04/27 - 20:45:13 | 200 | 28.976µs | 169.254.1.1 | GET "/healthz" W0427 20:45:16.346147 1 warnings.go:70] apisix.apache.org/v2beta1 ApisixRoute is deprecated; use apisix.apache.org/v2beta3 ApisixRoute [GIN] 2022/04/27 - 20:45:23 | 200 | 29.95µs | 169.254.1.1 | GET "/healthz" [GIN] 2022/04/27 - 20:45:23 | 200 | 24.161µs | 169.254.1.1 | GET "/healthz" [GIN] 2022/04/27 - 20:45:33 | 200 | 34.457µs | 169.254.1.1 | GET "/healthz" [GIN] 2022/04/27 - 20:45:33 | 200 | 24.054µs | 169.254.1.1 | GET "/healthz" [GIN] 2022/04/27 - 20:45:43 | 200 | 26.65µs | 169.254.1.1 | GET "/healthz" [GIN] 2022/04/27 - 20:45:43 | 200 | 24.778µs | 169.254.1.1 | GET "/healthz" [GIN] 2022/04/27 - 20:45:53 | 200 | 31.825µs | 169.254.1.1 | GET "/healthz" [GIN] 2022/04/27 - 20:45:53 | 200 | 21.546µs | 169.254.1.1 | GET "/healthz" [GIN] 2022/04/27 - 20:46:03 | 200 | 28.885µs | 169.254.1.1 | GET "/healthz" [GIN] 2022/04/27 - 20:46:03 | 200 | 23.01µs | 169.254.1.1 | GET "/healthz" [GIN] 2022/04/27 - 20:46:13 | 200 | 24.818µs | 169.254.1.1 | GET "/healthz" [GIN] 2022/04/27 - 20:46:13 | 200 | 22.304µs | 169.254.1.1 | GET "/healthz"
Expected result
Update the apisixRoute spec.http.name field and only one route appears
apisix-ingress-controller version 1.4.0 apisix version 2.13.1 etcdctl version: 3.4.18
This is not a bug, this is a concrete implementation.
For now we will use this name to construct the final route name.
If you update the ApisixRoute resource directly, since the metadata.name
has not changed, it will only synchronize the route according to the current configuration.
But the APISIX Ingress controller will not delete the original route information in APISIX, which is very dangerous. Unless you delete the ApisixRoute resource and re-create it with a new configuration.
I did not modify metadata.name ,I changed spec.http.name。 apisixroute1.yaml
apiVersion: apisix.apache.org/v2beta3
kind: ApisixRoute
metadata:
name: nginx
namespace: default
spec:
http:
- name: a981a76
match:
hosts:
- "test.apisixroute.com"
paths:
- "/*"
backends:
- serviceName: nginx
servicePort: 80
kubectl apply -f apisixroute1.yaml
kubectl describe ar nginx
dashboard
apisixroute2.yaml
apiVersion: apisix.apache.org/v2beta3
kind: ApisixRoute
metadata:
name: nginx
namespace: default
spec:
http:
- name: api
match:
hosts:
- "test.apisixroute.com"
paths:
- "/*"
backends:
- serviceName: nginx
servicePort: 80
kubectl apply -f apisixroute2.yaml
kubectl describe ar nginx
dashboard
The above is normal
In practice, however,in some cases,apisixRoute update will result in two route records in etcd,It looks like a new route record was created instead of updating the old route
If you update the ApisixRoute resource directly, since the
metadata.name
has not changed, it will only synchronize the route according to the current configuration.But the APISIX Ingress controller will not delete the original route information in APISIX, which is very dangerous. Unless you delete the ApisixRoute resource and re-create it with a new configuration.
Please read my previous comment
This issue has been marked as stale due to 90 days of inactivity. It will be closed in 30 days if no further activity occurs. If this issue is still relevant, please simply write any comment. Even if closed, you can still revive the issue at any time or discuss it on the [email protected] list. Thank you for your contributions.
This issue has been closed due to lack of activity. If you think that is incorrect, or the issue requires additional review, you can revive the issue at any time.