Better graceful restart with Kubernetes

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?

The two-timer idea fits the problem better than a fixed preSleep delay, especially with node termination. The key detail is stopping new connections before waiting on existing ones.

Right. How do we move forward with this proposal? Does it make sense to just file a feature request in the bug tracker with the text of my first message?

The devs are usually working with Github, make sure to reference your post here.

This is now better graceful restart with Kubernetes taking into account interval between incoming requests · Issue #13907 · traefik/traefik · GitHub