kubernetes: ipvs proxier doesn't respect graceful termination
Is this a BUG REPORT or FEATURE REQUEST?: /kind bug
What happened: Upon removing an endpoint, the ipvs proxier immediately deletes the ipvs real server, causing all connections to get dropped.
What you expected to happen: It should allow the terminating pod to gracefully close connections, just like the iptables proxier.
How to reproduce it (as minimally and precisely as possible):
- Enable ipvs proxier
- Create a keepalive / long lived connection to a pod (e.g.
while :; do echo -e "GET / HTTP/1.1\nhost: $host\n\n"; sleep 5; echo; done | telnet $serviceip 80) - Delete that pod - observe the connection gets closed immediately, further requests will fail. On iptables proxier, it will continue to work (until the pod itself stops or closes the connection).
Anything else we need to know?: The ipvs proxier should instead be setting weight to 0, then reaping the stale real servers after some time period (that should be greater than any pod’s graceful termination time). This may also fix the existing bug around UDP connections getting dropped prematurely (https://github.com/kubernetes/kubernetes/issues/45976).
Environment:
- Kubernetes version (use
kubectl version): tested on 1.8, but same issue in 1.9 afaict - Cloud provider or hardware configuration: AWS
- OS (e.g. from /etc/os-release): Ubuntu 16.04
- Kernel (e.g.
uname -a): 4.4.0 - Install tools:
- Others:
About this issue
- Original URL
- State: closed
- Created 6 years ago
- Comments: 32 (26 by maintainers)
I think it will break a lot of people’s expectations if IPVS doesn’t support graceful termination with at least TCP - this is the current behavior with iptables and userspace mode.
@jhorwit2 at this point, I don’t think this should block GA. However, we should prioritize releasing a fix for this in a patch release.
#64947?
@jsravn @m1093782566 @rramkumar1 @jhorwit2 Hi, guys. Recently I have been testing this issue, and got some result. Here is my test step:
Create a pod with
liseCycle/preStopspecified andterminationGracePeriodSeconds=300. Expose this pod to a service.Check this pod and service.
Use
telnettest service clusterIP connection.Use
kubectldelete pod, considering what we specified in podpreStop, this pod should be interminatingstatus for 300s.Check ipvs rules.
We can see ipvs realserver have been deleted, but
telnetstill in connection, and the connection is in stateESTABLISHEDwith an expire time 14m6s.After 5min, the container be deleted, telnet connection closed. Check ipvsadm connection.
So, according to my test, I think ipvs proxier should have graceful termination for lone lived connection. If you have any question or suggestion about the test process, please let me know. And I’d like people introduce other test process.
Hopefully you can fix this for UDP connections too, since iptables proxier suffers from a bug where it drops the udp connection immediately (causing errors when kube-dns is restarted for instance…). It’d be nice if the ipvs proxier could handle that better.