You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@apisix.apache.org by GitBox <gi...@apache.org> on 2022/03/17 13:14:18 UTC
[GitHub] [apisix-ingress-controller] cmssczy opened a new issue #924: bug: panic when apisixRoute resource's backends is not existed
cmssczy opened a new issue #924:
URL: https://github.com/apache/apisix-ingress-controller/issues/924
### Issue description
Create a ApisixRoute resource before start the apisix-ingress-controller and set the `backends` with a nonexistent service name. Then start the apisix-ingress-controller and it will panic.
The root cause is the failure of type assertion.
https://github.com/apache/apisix-ingress-controller/blob/c9e0c965cd2226e2c44aa4e692a8bf57d1586aa3/pkg/ingress/apisix_route.go#L267
Actually the type of this obj is `*types.Event` but not `string`.
https://github.com/apache/apisix-ingress-controller/blob/c9e0c965cd2226e2c44aa4e692a8bf57d1586aa3/pkg/ingress/apisix_route.go#L353-L359
After I check the other resources' logic, I find that sometimes we push `string` to workqueue, but sometimes we push `*types.Event`.
How to evaluate the benefits of doing so? Why did we use different method to handle different resources?
### Environment
- your apisix-ingress-controller version (output of apisix-ingress-controller version --long):apisix-ingress-controller version 1.4.0-c9e0c96-go1.17.7
- 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
1. Create a ApisixRoute resource before start the apisix-ingress-controller and set the `backends` with a nonexistent service name
2. Start apisix-ingress-controller
### Actual result
The process will panic.
### Error log
```
2022-03-17T20:43:20+08:00 error translation/apisix_route.go:344 failed to get service port in backend {"backend": {"serviceName":"httpbin","servicePort":80,"weight":null}, "apisix_route": {"kind":"ApisixRoute","apiVersion":"apisix.apache.org/v2beta3","metadata":{"name":"httpbin-route","namespace":"default","uid":"5d4a8c99-649e-4ac7-bc71-59c4422d93cb","resourceVersion":"5298724","generation":1,"creationTimestamp":"2022-03-17T12:34:03Z","annotations":{"kubectl.kubernetes.io/last-applied-configuration":"{\"apiVersion\":\"apisix.apache.org/v2beta3\",\"kind\":\"ApisixRoute\",\"metadata\":{\"annotations\":{},\"name\":\"httpbin-route\",\"namespace\":\"default\"},\"spec\":{\"http\":[{\"backends\":[{\"serviceName\":\"httpbin\",\"servicePort\":80}],\"match\":{\"hosts\":[\"httpbin.com\"],\"paths\":[\"/headers\"]},\"name\":\"rule1\"}]}}\n"},"managedFields":[{"manager":"kubectl-client-side-apply","operation":"Update","apiVersion":"apisix.apache.org/v2beta3","time":"2022-03-17T12:34:03Z","field
sType":"FieldsV1","fieldsV1":{"f:metadata":{"f:annotations":{".":{},"f:kubectl.kubernetes.io/last-applied-configuration":{}}},"f:spec":{".":{},"f:http":{}}}}]},"spec":{"http":[{"name":"rule1","match":{"paths":["/headers"],"hosts":["httpbin.com"]},"backends":[{"serviceName":"httpbin","servicePort":80,"weight":null}],"websocket":false,"authentication":{"enable":false,"type":"","keyauth":{}}}]},"status":{}}, "error": "service \"httpbin\" not found"}
2022-03-17T20:43:20+08:00 error ingress/apisix_route.go:174 failed to translate ApisixRoute v2beta3 {"error": "service \"httpbin\" not found", "object": {}}
panic: interface conversion: interface {} is kube.ApisixRouteEvent, not string
goroutine 281 [running]:
github.com/apache/apisix-ingress-controller/pkg/ingress.(*apisixRouteController).handleSyncErr(0xc00029a380, {0x16cff20, 0xc000781830}, {0x1c8bc00, 0xc000390f00})
/root/apisix/apisix-ingress-controller/pkg/ingress/apisix_route.go:267 +0x18c9
github.com/apache/apisix-ingress-controller/pkg/ingress.(*apisixRouteController).runWorker(0xc00029a380, {0x1cbd710, 0xc0000a8c40})
/root/apisix/apisix-ingress-controller/pkg/ingress/apisix_route.go:84 +0x92
created by github.com/apache/apisix-ingress-controller/pkg/ingress.(*apisixRouteController).run
/root/apisix/apisix-ingress-controller/pkg/ingress/apisix_route.go:71 +0x265
```
### Expected result
_No response_
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@apisix.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [apisix-ingress-controller] tao12345666333 edited a comment on issue #924: bug: panic when apisixRoute resource's backends is not existed
Posted by GitBox <gi...@apache.org>.
tao12345666333 edited a comment on issue #924:
URL: https://github.com/apache/apisix-ingress-controller/issues/924#issuecomment-1071228991
No reproduction in my environment.
```bash
root@zhangjintao-1:~/apisix# kubectl scale -n apisix deploy/apisix-ingress-controller --replicas=0 deployment.apps/apisix-ingress-controller scaled root@zhangjintao-1:~/apisix# kubectl -n apisix apply -f non-exist.yaml
apisixroute.apisix.apache.org/non-exist created
root@zhangjintao-1:~/apisix# kubectl get ar -A NAMESPACE NAME HOSTS URIS AGE
apisix non-exist ["non-exist.org"] ["/*"] 4s
root@zhangjintao-1:~/apisix# kubectl -n apisix get deploy
NAME READY UP-TO-DATE AVAILABLE AGE
apisix 1/1 1 1 6m21s
apisix-ingress-controller 0/0 0 0 6m21s
root@zhangjintao-1:~/apisix# kubectl scale -n apisix deploy/apisix-ingress-controller --replicas=1
deployment.apps/apisix-ingress-controller scaled
root@zhangjintao-1:~/apisix# kubectl -n apisix get deploy
NAME READY UP-TO-DATE AVAILABLE AGE
apisix 1/1 1 1 6m35s
apisix-ingress-controller 1/1 1 1 6m35s
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@apisix.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [apisix-ingress-controller] gxthrj closed issue #924: bug: panic when apisixRoute resource's backends is not existed
Posted by GitBox <gi...@apache.org>.
gxthrj closed issue #924:
URL: https://github.com/apache/apisix-ingress-controller/issues/924
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@apisix.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [apisix-ingress-controller] tao12345666333 edited a comment on issue #924: bug: panic when apisixRoute resource's backends is not existed
Posted by GitBox <gi...@apache.org>.
tao12345666333 edited a comment on issue #924:
URL: https://github.com/apache/apisix-ingress-controller/issues/924#issuecomment-1071228991
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@apisix.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [apisix-ingress-controller] gxthrj closed issue #924: bug: panic when apisixRoute resource's backends is not existed
Posted by GitBox <gi...@apache.org>.
gxthrj closed issue #924:
URL: https://github.com/apache/apisix-ingress-controller/issues/924
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@apisix.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [apisix-ingress-controller] tao12345666333 commented on issue #924: bug: panic when apisixRoute resource's backends is not existed
Posted by GitBox <gi...@apache.org>.
tao12345666333 commented on issue #924:
URL: https://github.com/apache/apisix-ingress-controller/issues/924#issuecomment-1071228991
what's your apisix-ingress-controller's version? No reproduction in my environment.
```bash
root@zhangjintao-1:~/apisix# kubectl scale -n apisix deploy/apisix-ingress-controller --replicas=0 deployment.apps/apisix-ingress-controller scaled root@zhangjintao-1:~/apisix# kubectl -n apisix apply -f non-exist.yaml
apisixroute.apisix.apache.org/non-exist created
root@zhangjintao-1:~/apisix# kubectl get ar -A NAMESPACE NAME HOSTS URIS AGE
apisix non-exist ["non-exist.org"] ["/*"] 4s
root@zhangjintao-1:~/apisix# kubectl -n apisix get deploy
NAME READY UP-TO-DATE AVAILABLE AGE
apisix 1/1 1 1 6m21s
apisix-ingress-controller 0/0 0 0 6m21s
root@zhangjintao-1:~/apisix# kubectl scale -n apisix deploy/apisix-ingress-controller --replicas=1
deployment.apps/apisix-ingress-controller scaled
root@zhangjintao-1:~/apisix# kubectl -n apisix get deploy
NAME READY UP-TO-DATE AVAILABLE AGE
apisix 1/1 1 1 6m35s
apisix-ingress-controller 1/1 1 1 6m35s
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@apisix.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [apisix-ingress-controller] tao12345666333 commented on issue #924: bug: panic when apisixRoute resource's backends is not existed
Posted by GitBox <gi...@apache.org>.
tao12345666333 commented on issue #924:
URL: https://github.com/apache/apisix-ingress-controller/issues/924#issuecomment-1071228991
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@apisix.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [apisix-ingress-controller] tao12345666333 edited a comment on issue #924: bug: panic when apisixRoute resource's backends is not existed
Posted by GitBox <gi...@apache.org>.
tao12345666333 edited a comment on issue #924:
URL: https://github.com/apache/apisix-ingress-controller/issues/924#issuecomment-1071228991
No reproduction in my environment.
```bash
root@zhangjintao-1:~/apisix# kubectl scale -n apisix deploy/apisix-ingress-controller --replicas=0 deployment.apps/apisix-ingress-controller scaled root@zhangjintao-1:~/apisix# kubectl -n apisix apply -f non-exist.yaml
apisixroute.apisix.apache.org/non-exist created
root@zhangjintao-1:~/apisix# kubectl get ar -A NAMESPACE NAME HOSTS URIS AGE
apisix non-exist ["non-exist.org"] ["/*"] 4s
root@zhangjintao-1:~/apisix# kubectl -n apisix get deploy
NAME READY UP-TO-DATE AVAILABLE AGE
apisix 1/1 1 1 6m21s
apisix-ingress-controller 0/0 0 0 6m21s
root@zhangjintao-1:~/apisix# kubectl scale -n apisix deploy/apisix-ingress-controller --replicas=1
deployment.apps/apisix-ingress-controller scaled
root@zhangjintao-1:~/apisix# kubectl -n apisix get deploy
NAME READY UP-TO-DATE AVAILABLE AGE
apisix 1/1 1 1 6m35s
apisix-ingress-controller 1/1 1 1 6m35s
```
UPDATE:
The problem is reproduced.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@apisix.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [apisix-ingress-controller] tao12345666333 commented on issue #924: bug: panic when apisixRoute resource's backends is not existed
Posted by GitBox <gi...@apache.org>.
tao12345666333 commented on issue #924:
URL: https://github.com/apache/apisix-ingress-controller/issues/924#issuecomment-1071930959
Thanks for your feedback, after I reproduced, I submitted a PR to fix it.
I'll answer your question about why we designed it this way later
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@apisix.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org