istio: Ambient: Error: listen EADDRINUSE: address already in use
Is this the right place to submit this?
- This is not a security vulnerability or a crashing bug
- This is not a question about how to use Istio
Bug Description
When I deploy our application to a test environment, where Ambient mesh is enabled, some pods will get into CrashLoop state, where they state, that the port they try to bind is already in use. If I delete the pod and it gets re-scheduled, the error mostly disappears.
When I remove the dataplane-mode: ambient label from the namespace and re-deploy the application, everything works as expected, I don’t think that this is an application issues, we run this in production stable. We have never seen this issue before anywhere else.
For each pod, we have the following setup:
- the pod exposes port 8080 (api) and 8081 (monitoring)
- each pod has two k8s serivce, one for api access , one for monitoring
- api: k8s service listens on port 80 -> pod exposes port 8080
- monitoring: k8s service listens on port 8081 -> pod exposes port 8081
Things I tried:
- We only see issues with the monitoring port, first I thought that there might be a collision when the k8s service is also listening on the same port as the target port, but I tried to change it to a different port -> no luck.
- Tried to find some connections between the node and when the problem occures -> nothing
- Waypoint proxy/ingress is running on different nodes
I don’t see any error logs in either the cni or the ztunnel pods. If I understand right, the cni connects to the pods’ network namespace just to inject iptables rules, so it shouldn’t really mess with the bindings.
Output from the pod:
{"message":"Error: listen EADDRINUSE: address already in use :::8081","timestamp":"2024-07-23T09:28:44.571Z","hostname":"XXXX-XXXX-wrxsb","pid":1,"module":"service:graceful","type":"uncaughtException","stack":"Error: listen EADDRINUSE: address already in use :::8081\n at Server.setupListenHandle [as _listen2] (node:net:1817:16)\n at listenInCluster (node: net:1865:12)\n at Server.listen (node:net:1953:7)\n at MonitoringService.listen (/src/node_modules/XXX/lib/application.js:89:19)\n at /src/node_modules/@XXX/api/dist/monitoring-service.js:45:32\n at new Promise (<anonymous>)\n at MonitoringService.start (/src/node_modules/@XXX/api/dist/monitoring-service.js:40:16)\n at /src/node_modules/@XXX/service/dist/service.types.js:75:31\n at Array.map (<anonymous>)\n at Object.start (/src/node_modules/@XXX/service/dist/service.types.js:67:47)","error":{"code":"EADDRINUSE","errno": -98,"syscall":"listen","address":"::","port":8081},"level":"error"}
Version
client version: 1.22.1
control plane version: 1.22.3
data plane version: 1.22.3 (48 proxies)
Client Version: v1.29.0
Kustomize Version: v5.0.4-0.20230601165947-6ce0bf390ce3
Server Version: v1.29.4-eks-036c24b
Additional Information
No response
About this issue
- Original URL
- State: closed
- Created 2 years ago
- Reactions: 1
- Comments: 33 (21 by maintainers)
Hey folks, as the PR fixing this merged this got auto closed. Currently this is on 1.24/master branch only. If you want to try it out you can pull down https://github.com/istio/istio/wiki/Dev Builds. Likely, once we get a bit more testing under this, we will backport this to 1.23 off by default
@howardjohn, I change on the pod, step 1-2 -> everything is fine, when I change the port it rolls out a new pod and then the probe starts to fail -> it’s unable to bind.
@bleggett, same, I think there’s some race condition or something when the container restarts.
I can’t really put more time into the PoC, I think we can close this issue, maybe someone will face something similar then we can continue 😃
Thanks
I struggle to see how ztunnel can cause this. Ztunnel does not listen on port 8081. Obviously the symptoms point to that, it just seems bizzare.
I think the best way to debug this is to get it into this state, then attach an ephemeral container and run
netstat -ntlp. Though I think-ponly works with share pid namespace…But basically want to see what is listening on the port.
also just to double check, its not a hostNetwork pod right?