kubernetes: Impossible to notice without major delay when a container exits while the POD is in terminating state
What happened?
When a POD which is part of a service starts graceful termination, and the main container exits the related endpoint in endpointslice does not go to serving=false. Only after readiness probe fails will the endpoint enter serving=false state. Which doesn’t make sense in my opinion.
I also tried watching for POD changes and determine that the container exited based on container_statuses list. But there I hit this issue: https://github.com/kubernetes/kubernetes/issues/106896
Then I tried to remove the label which selects the POD as an endpoint by the service, but then I experienced ~5s delay till kubernetes notified that the endpoint has disappeared.
What did you expect to happen?
The endpoint should go to serving=false when any container exits in a POD which is under graceful termination. Also the alternatives I tried should have worked I think.
How can we reproduce it (as minimally and precisely as possible)?
Create a POD with 2 containers, 1 which exits immediately after receiving SIGTRERM, the other doesn’t so it is killed by SIGKILL after termination grace period. The first container should also have a readiness probe which doesn’t fail quick. ex.: period 5s, failureThreshold 3. Make the POD be part of a service. Delete the pod. Check the endpoint in the endpointslice only going to serving=false, after the readiness probe fails.
Anything else we need to know?
No response
Kubernetes version
kubectl version Client Version: v1.28.1 Kustomize Version: v5.0.4-0.20230601165947-6ce0bf390ce3 Server Version: v1.29.1
Cloud provider
N/A
OS version
# On Linux:
$ cat /etc/os-release
# paste output here
$ uname -a
# paste output here
# On Windows:
C:\> wmic os get Caption, Version, BuildNumber, OSArchitecture
# paste output here
Install tools
Container runtime (CRI) and version (if applicable)
Related plugins (CNI, CSI, …) and versions (if applicable)
About this issue
- Original URL
- State: open
- Created 2 years ago
- Comments: 16 (7 by maintainers)
i think if a container that’s handling requests exits, it’s important that the endpoint stops serving traffic quickly.