简体   繁体   English

Spring Boot 2.3 Liveness Probe 功能无法正常关机

[英]Spring Boot 2.3 Liveness Probe feature fails in graceful shutdown

I'm testing the new feature graceful shutdown in Spring Boot 2.3 ( server.shutdown=graceful and Tomcat Web server ) with Kubernetes terminationGracePeriodSeconds field. I'm testing the new feature graceful shutdown in Spring Boot 2.3 ( server.shutdown=graceful and Tomcat Web server ) with Kubernetes terminationGracePeriodSeconds field. When the graceful shutdown phase starts, new HTTP requests are rejected as expected and in this time the current requests should be elaborated until configurable timeout ( spring.lifecycle.timeout-per-shutdown-phase ).当正常关闭阶段开始时,新的 HTTP 请求将按预期被拒绝,此时应详细说明当前请求,直到可配置的超时( spring.lifecycle.timeout-per-shutdown-phase )。 The strange behavior is the Spring boot actuator liveness result because, in this scenario, the liveness endpoint is unreachable.奇怪的行为是 Spring 启动执行器活性结果,因为在这种情况下,活性端点无法访问。

So kubelet cannot know if the microservice is still alive during the shutdown or stuck for other things.因此,kubelet 无法知道微服务在关闭期间是否还活着,或者因为其他事情而卡住了。 Since the K8s liveness probe doesn't rely on terminationGracePeriodSeconds field, the POD will restart according to its K8s liveness configuration and Spring boot microservice cannot perform the graceful shutdown due to brutal restart.由于K8s liveness probe不依赖terminationGracePeriodSeconds字段,POD会根据自己的K8s liveness配置重启,Spring boot微服务由于野蛮重启无法正常关闭。

Am I missing something?我错过了什么吗? How could I manage this scenario?我该如何管理这种情况?

In meanwhile, I've adopted another solution, I'm invoking the liveness probe of spring boot via JMX using RMI protocol.同时,我采用了另一种解决方案,我正在使用 RMI 协议通过 JMX 调用 spring 启动的活性探针。 In this case, the liveness gives an "UP" response during the graceful shutdown.在这种情况下,liveness 在正常关闭期间给出“UP”响应。 To do this: enable JMX setting the property spring.jmx.enabled to true and the liveness invoke JMX Health indicator using a JMX client.为此:启用 JMX,将属性spring.jmx.enabled设置为 true 并使用 JMX 客户端调用 JMX 健康指标。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM