The current recommendation to gracefully handle Kubernetes-initiated restarts is to add a preSleep hook. This generally works but is subject to race conditions and delays the restart for longer than strictly necessary (sometimes to the point of exceeding the actual grace time e.g. during node termination).
An alternative proposal is to update the Traefik signal handler to behave thus:
(a) define two new configuration directives graceful_shutdown_new_connection_max_interval and graceful_shutdown_max_delay
(b) when receiving the signal, start two timers time_since_shutdown_request, time_since_new_inbound_request
(c) actually shutdown once time_since_new_inbound_request >= graceful_shutdown_new_connection_max_interval or time_since_shutdown_request >= graceful_shutdown_max_delay
Would that proposal make sense? Is anything similar in the works already? I couldn't find anything relevant in the bug tracker but I might be searching it wrong. Or maybe this is already possible currently but I didn't find how?