-
Notifications
You must be signed in to change notification settings - Fork 41.1k
Liveness/Readiness probes failure while using graceful shutdown #24617
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
@paoven Have you seen the kubernetes deployment section in the reference documentation? We assume that the graceful shutdown sequence should start once the platform has stopped routing traffic to the application instance. The shutdown delay really depends on the platform (in your case the readiness check period, which is configurable). We're considering adding an optional delay in #20995 - but a possible solution here is to configure a |
@bclozel Thanks for prompt answer. I was able to obtain a clean shutdown (both on client and server side) by leveraging on preStop hook and a sleeping thread which introduces the mentioned delay. About the relation between the shutdown delay and readiness check period, as far as I can see Kubernetes is not relying on liveness/readiness checks anymore as soon as the Pod enters Terminating state but of course the delay is necessary in order to guarantee that the platform removes the Pod reference from Services/RS/ and has effectively stopped sending traffic to it). Thanks again, kind regards |
The problem with |
@jcook793 as far as I understoop preStop delay is just necessary to let the platform/load balancer to stop routing new traffic to the shutting down service (In Kubernetes should be 5/10 seconds according to this useful article). Already existing connections are not forcibly dropped at this stage. In the upload example you mentioned, when Spring Boot receives the SIGTERM signal, it will wait for pending requests to terminate up to the maximum shutdown timeout (e.g. spring.lifecycle.timeout-per-shutdown-phase configured to 3mins), but if there are no requests it will shutdown fast without waiting 3 minutes. |
The documentation is still wrong, because it states that during the graceful shutdown period the liveness probe should report LIVE state, but both endpoints are unreachable. |
@lturcsanyi could you quote here exactly the section that states this? |
Sorry, I linked a wrong section, in the "Application lifecycle and Probes states" section, the second table: "When a Spring Boot application shuts down:" |
Thanks for the feedback @lturcsanyi , I've created #24843 |
Hi! While I was investigating on Spring Boot graceful shutdown feature as well as liveness/readiness endpoints (to be called at a later stage from Kubernetes probes) I discovered that the mentioned endpoints become unreacheble as soon as shutdown is initiated by a SIGTERM. This would cause Kubernetes liveness probe fail and may lead to unclean shutdown. As the purpose of graceful shutdown is the opposite I filled this report.
I created a sample Spring Boot project on GitHub to simplify issue testing. The service exposes a controller that, when invoked, will sleep for the desired amount of time.
Please see instructions to reproduce the issue below. Many thanks for your support, best regards
Paolo
Environment:
How to reproduce:
The text was updated successfully, but these errors were encountered: