kubernetes: long living TCP connections hang when pod behind a ClusterIP service is restart

What happened?

I’ve got a service of type ClusterIP with a singe pod backing it. When the pod backing the service is restarted, it gets a new IP and all existing TCP connection just stall.

What did you expect to happen?

The next packet belonging to existing TCP connections should get a TCP RST.

How can we reproduce it (as minimally and precisely as possible)?

  • use a ClusterIP service with a single backing pod
  • establish a long living TCP connection (ssh might work, we used HTTP2)
  • kill the pod
  • watch the connection stalling

Anything else we need to know?

No response

Kubernetes version

$ kubectl version
Client Version: v1.29.3
Kustomize Version: v5.0.4-0.20230601165947-6ce0bf390ce3
Server Version: v1.27.12+rke2r1

Cloud provider

Euqinix Metal

OS version

# On Linux:
$ cat /etc/os-release
PRETTY_NAME="Ubuntu Noble Numbat (development branch)"
NAME="Ubuntu"
VERSION_ID="24.04"
VERSION="24.04 LTS (Noble Numbat)"
VERSION_CODENAME=noble
ID=ubuntu
ID_LIKE=debian
HOME_URL="https://www.ubuntu.com/"
SUPPORT_URL="https://help.ubuntu.com/"
BUG_REPORT_URL="https://bugs.launchpad.net/ubuntu/"
PRIVACY_POLICY_URL="https://www.ubuntu.com/legal/terms-and-policies/privacy-policy"
UBUNTU_CODENAME=noble
LOGO=ubuntu-logo
$ uname -a
Linux zeus 6.8.0-22-generic #22-Ubuntu SMP PREEMPT_DYNAMIC Thu Apr  4 22:30:32 UTC 2024 x86_64 x86_64 x86_64 GNU/Linux

Install tools

Container runtime (CRI) and version (if applicable)

Related plugins (CNI, CSI, …) and versions (if applicable)

About this issue

  • Original URL
  • State: closed
  • Created 3 years ago
  • Comments: 22 (19 by maintainers)

Most upvoted comments

Go sets the TCP keep-alive time to 15s, and I was confused that the client still hangs for 15m

https://blog.cloudflare.com/when-tcp-sockets-refuse-to-die

The cluster and setup that had the problem has be deprovisioned, I can therefore not be sure about the exact setup. I do know that it was using calico, but it could have been in nft or iptables mode.

I will have another look at this. It may be CNI-plugin specific (https://github.com/kubernetes/kubernetes/issues/124290#issuecomment-2051586556)

/assign