Since Spring Boot 3.0.6, Liveness and Readiness probes return 503 (DOWN)

With this configuration :

spring:
  main:
    lazy-initialization: true
    cloud-platform: KUBERNETES
management:
  security:
    enabled: false
  endpoints:
    web.exposure.include: info,health,prometheus

The following test is red :

@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)
@AutoConfigureObservability
class SupervisionIntegrationTest {

    @Autowired
    lateinit var restTemplate: TestRestTemplate

    @Test
    fun livenessProbe() {
        val response = restTemplate.getForEntity("/actuator/health/liveness", String::class.java)
        assertThat(response.statusCode).isEqualTo(HttpStatus.OK)
    }

    @Test
    fun readinessProbe() {
        val response = restTemplate.getForEntity("/actuator/health/readiness", String::class.java)
        assertThat(response.statusCode).isEqualTo(HttpStatus.OK)
    }

}

The same test with Spring Boot 3.0.5 is ok. With 3.0.6, if spring.main.cloud-platform is removed, the health probe is ok. When k8s probes are added, the health becomes down.

Comment From: quaff

I cannot reproduce it.

Comment From: wilkinsona

Thanks for trying, @quaff.

@Storje, if you would like us to spend some more time investigating, please spend some time providing a complete yet minimal sample that reproduces the problem. You can share it with us by pushing it to a separate repository on GitHub or by zipping it up and attaching it to this issue. Unless the problem is specific to Kotlin, the sample should ideally be written in Java as it removes one possible source of problems.

Comment From: marcoranica94

Since Spring Boot 3.0.6, Liveness and Readiness probes return 503 (DOWN)

With this configuration :

yaml spring.main.cloud-platform: KUBERNETES management: security: enabled: false endpoints: web.exposure.include: info,health,prometheus

The following test is red :

```kotlin @SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT) @AutoConfigureObservability class SupervisionIntegrationTest {

@Autowired
lateinit var restTemplate: TestRestTemplate

@Test
fun livenessProbe() {
    val response = restTemplate.getForEntity("/actuator/health/liveness", String::class.java)
    assertThat(response.statusCode).isEqualTo(HttpStatus.OK)
}

@Test
fun readinessProbe() {
    val response = restTemplate.getForEntity("/actuator/health/readiness", String::class.java)
    assertThat(response.statusCode).isEqualTo(HttpStatus.OK)
}

} ```

The same test with Spring Boot 3.0.5 is ok. With 3.0.6, if spring.main.cloud-platform is removed, the health probe is ok. When k8s probes are added, the health becomes down.

Hi, we have updated spring 3.0.6 and appeared to us same problem. The problem seems to have temporarily resolved with the addition of this label in application.yml: cloud-platform: none

Comment From: Storje

The issue is when lazy init is enabled. The configuration in first message is updated with the right configuration.

Comment From: quaff

I verified health down with

spring.main:
  lazy-initialization: true
  cloud-platform: kubernetes

Comment From: marcorotondi

Since Spring-Boot 3.0.6 and Spring-Clound 2022.0.2 The problem occurs randomly.

On the same service released in a docker environment, one service returns DOWN while the other returns UP by entering

spring.main.cloud-platform=none

The problem no longer occurs. The only difference from other services is the activation of lazy-loading:

spring.main. lazy-initialization=true

it seems that lazy-initialization does not lead to the creation of the necessary beans

Problem solved with: spring.main. lazy-initialization=false and without this: spring.main.cloud-platform=none

Comment From: Storje

@wilkinsona here is a sample to reproduce the issue demo.zip

Comment From: wilkinsona

Thanks, @Storje. I've yet to figure out why it makes a difference, but the problem can be worked around by preventing the ApplicationAvailability bean from being marked as lazy:

@Bean
fun eagerApplicationAvailabilityBean(): LazyInitializationExcludeFilter {
    return LazyInitializationExcludeFilter.forBeanTypes(ApplicationAvailability::class.java)
}

Comment From: wilkinsona

This is a regression caused by the changes for https://github.com/spring-projects/spring-boot/pull/34347. The return type of the @Bean method has changed from ApplicationAvailabilityBean to ApplicationAvailability. This means that type information is lost and the bean factory cannot tell that it's an ApplicationListener.