SpringBoot 2.1.9 ->2.2.0 - 健康端点不再有效 [英] SpringBoot 2.1.9 -> 2.2.0 - health endpoint no longer works
问题描述
尝试升级到 Spring 2.2.0 并且我的 /health
端点不再有效,这会导致我的 AWS ALB 运行状况检查出现问题.
Trying to upgrade to Spring 2.2.0 and my /health
endpoint no longer works, which causes problems with my AWS ALB health-checking.
为什么我的健康端点现在不起作用?
Why does my health endpoint not work now?
相关application.properties
:
# specifies that actuator endpoints be published on separate port
management.server.port=8081
# spring boot 2 moved this under "/actuator" but I don't like it, so this
management.endpoints.web.base-path=/
# This makes the /health endpoint return "status:UP" when the
# DB cannot be reached.
# Without this, overall status depends on datasource status.
#
# This is needed on the AWS side because ELB healthchecks used for ASG, so
# when DB became unreachable (because of RDS maintenance or other stuff-ups) or
# was just not reliably reachable (becaue of load testing resulting in
# connection pool exhaustion) - the ASG would start cycling instances
# unnecessarily.
management.health.defaults.enabled = false
相关Spring配置:
Relevant Spring config:
public static String[] anonymousUrlPatterns(){
return new String[] {
// unauthenticated so the ELB can call it
HEALTH_URL,
// unauthenticated because that's what browsers do
FAV_ICON_URL,
...
}
}
private void configureEndpointRoles(HttpSecurity http) throws Exception{
http.authorizeRequests().
antMatchers(anonymousUrlPatterns()).permitAll().
...
anyRequest().denyAll()
;
}
@Override
protected void configure(HttpSecurity http) throws Exception{
this.configureSsl(http);
this.configureEndpointRoles(http);
http.csrf().disable();
http.sessionManagement().sessionCreationPolicy(STATELESS);
http.httpBasic().disable();
http.cors();
this.configureExceptionHandling(http);
...
}
这是我用来检查本地机器的命令:
This is the command that I use to check on a local machine:
curl -v http://localhost:8081/health
在 2.1.9 上,curl 返回 {"status":"UP"}
- 在 2.2.0 上我没有收到任何响应.
On 2.1.9, the curl returns {"status":"UP"}
- on 2.2.0 I get no response.
推荐答案
原来这是由 management.health.defaults.enabled = false
Spring 人员再次摆弄执行器端点,现在数据库状态不再显示作为健康状态的一部分.
The Spring folks have been fiddling with the actuator endpoints again and now the database status doesn't display as part of the health status any more.
与此同时,他们似乎已经将设置重新调整为现在意味着完全禁用健康端点".
At the same time, it seems they've re-purposed the setting to now mean "completely disable the health endpoint".
对于奖励积分,尽管 DB 状态不再显示作为 /health
端点的一部分,但它现在已退化为失败并报告 DOWN代码>如果数据库不可访问.
And for bonus points, though the DB status no longer displays as part of the /health
endpoint, it's regressed to now fail and report DOWN
if the DB is unreachable.
这篇关于SpringBoot 2.1.9 ->2.2.0 - 健康端点不再有效的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!