feat: add drain delay to graceful shutdown process - #9211
Conversation
✅ Deploy Preview for cerulean-figolla-1f9435 ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## main #9211 +/- ##
==========================================
- Coverage 75.21% 75.17% -0.05%
==========================================
Files 252 252
Lines 41049 41074 +25
==========================================
+ Hits 30877 30878 +1
- Misses 8078 8098 +20
- Partials 2094 2098 +4 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
|
@zirain Thanks for the speedy approval! What are the next steps for me? |
|
can you fix the conlfict and we need another approval from other maintainers. |
drainDelay defines how long the shutdown manager waits before failing healthchecks (delaying call to healthcheck/fail). The delay allows external load balancers time to deregister a terminating pod while still serving traffic. Signed-off-by: Michael Wain <michael@sanity.io>
When a pod terminates, the shutdown-manager immediately calls `healthcheck/fail` to fail health checks. This causes the readiness probe to fail and removes the pod from service endpoints. External load balancers that use health checks for deregistration need several failed probes before they stop sending new connections to the pod. On GKE, the L4 passthrough load balancer probes every 3 seconds and needs 2 failures (at the time of writing), so deregistration takes 6 seconds or more. The pod readiness probe fails faster than that, so for a few seconds the load balancer keeps sending connections that kube-proxy no longer routes. Kubernetes has a mechanism for this window. When a service has no other ready endpoints, kube-proxy keeps routing to terminating pods that still pass their readiness probe (KEP-1669). This only works if the pod keeps passing its probe while the load balancer deregisters it. Calling `healthcheck/fail` at the start of shutdown breaks that. This adds a drainDelay field to ShutdownConfig which delays the `healthcheck/fail` call. During the delay the pod stays ready and keeps serving, so the load balancer has time to deregister it. The ready-timeout and termination grace period are extended by the delay. Signed-off-by: Michael Wain <michael@sanity.io>
Signed-off-by: zirain <zirain2009@gmail.com>
|
I considered an alternative change to this in #9210 (comment), not sure whats best. (EDIT: PR in #9363) @mwain what do you think about delaying drain and readiness failure vs just delaying readiness failure? |
|
This pull request has been automatically marked as stale because it has not had activity in the last 30 days. Please feel free to give a status update now, ping for review, when it's ready. Thank you for your contributions! |
What type of PR is this?
feat
What this PR does / why we need it:
When a pod terminates, the shutdown-manager immediately calls
healthcheck/fail. This fails the readiness probe and removes the pod from service endpoints within ~5s.External load balancers that use health checks for deregistration need longer than that. On GKE, the L4 passthrough load balancer probes every 3 seconds and needs 2 failures, so deregistration takes 6 seconds or more. In between, the load balancer keeps sending new connections that kube-proxy no longer routes. They are reset or hang until they time out.
Kubernetes handles this window via KEP-1669. When no other ready endpoints remain, kube-proxy keeps routing to terminating pods that still pass their readiness probe. Failing readiness at the start of shutdown defeats this.
This adds a
drainDelayfield toShutdownConfigwhich delays thehealthcheck/failcall.During the delay the pod stays ready and keeps serving, so the load balancer has time to deregister it.
Which issue(s) this PR fixes:
Fixes #9210
Release Notes: Yes