I started to use the new graceful shutdown feature of spring boot. When running on kubernetes, the readiness probe is usually done periodically (i.e. every 5 seconds). When the application receives a termination signal, the readiness state is changed to "OUT_OF_SERVICE" and the application stops accepting requests. Kubernetes still routes traffic to the application until it picks up the changed readiness state (in our scenarion at least after 5 seconds). Therefore, I would like to configure a time that the application waits before actually starting the graceful shutdown and during which the application still accepts incoming requests.

Maybe I have overseen something here. If not, a configuration property for this would be very useful.

So far, I added it myself with an additional ApplicationListener using a Thread.sleep() inside it. But since this is now a built-in Spring Boot feature it would be awesome if this is also provided right out-of-the-box.

Comment From: wilkinsona

Thanks for the suggestion. Our current recommendation is to configure a pre-stop handler. #20995 is adding the delay to Spring Boot itself.