Skip to content
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

When configure management.port,readiness/runtime health check result may return success in app startup process #313

Closed
straybirdzls opened this issue Dec 26, 2018 · 0 comments
Assignees
Labels
bug Something isn't working
Milestone

Comments

@straybirdzls
Copy link
Member

straybirdzls commented Dec 26, 2018

Configure management.port=8081 , then in app startup process, when access http://localhost:8081/health or http://localhost:8081/health/readiness will get 200, which means app already start up success.

The reason : 8081 is opened before app startup finish. Port 8081 is open by org.springframework.boot.actuate.autoconfigure.EndpointWebMvcAutoConfiguration after root application initialize all beans(before ContextRefreshedEvent)

Override
public void afterSingletonsInstantiated() {
    ManagementServerPort managementPort = ManagementServerPort.DIFFERENT;
    if (this.applicationContext instanceof WebApplicationContext) {
        managementPort = ManagementServerPort
                .get(this.applicationContext.getEnvironment(), this.beanFactory);
    }
    if (managementPort == ManagementServerPort.DIFFERENT) {
        if (this.applicationContext instanceof EmbeddedWebApplicationContext
                && ((EmbeddedWebApplicationContext) this.applicationContext)
                        .getEmbeddedServletContainer() != null) {
            createChildManagementContext();
        }
        else {
            logger.warn("Could not start embedded management container on "
                    + "different port (management endpoints are still available "
                    + "through JMX)");
        }
    }
    if (managementPort == ManagementServerPort.SAME) {
        if (new RelaxedPropertyResolver(this.applicationContext.getEnvironment(),
                "management.ssl.").getProperty("enabled") != null) {
            throw new IllegalStateException(
                    "Management-specific SSL cannot be configured as the management "
                            + "server is not listening on a separate port");
        }
        if (this.applicationContext
                .getEnvironment() instanceof ConfigurableEnvironment) {
            addLocalManagementPortPropertyAlias(
                    (ConfigurableEnvironment) this.applicationContext
                            .getEnvironment());
        }
    }
}

However readiness healthcheck is done after ContextRefreshedEvent , and in isle scenario , all sofaboot modules are refreshed after ContextRefreshedEvent .

The early result 200 may cause serious problems on production.

@straybirdzls straybirdzls added the bug Something isn't working label Dec 26, 2018
@straybirdzls straybirdzls added this to the 2.6.0 milestone Dec 26, 2018
@straybirdzls straybirdzls changed the title When configure management.port,in app startup process,HealthCheckManager will throw NPE When configure management.port,in app startup process,readiness/runtime health check result will return succes Dec 29, 2018
@straybirdzls straybirdzls changed the title When configure management.port,in app startup process,readiness/runtime health check result will return succes When configure management.port,in app startup process,readiness/runtime health check result may return succes Dec 29, 2018
@straybirdzls straybirdzls changed the title When configure management.port,in app startup process,readiness/runtime health check result may return succes When configure management.port,readiness/runtime health check result may return success in app startup process Dec 29, 2018
@straybirdzls straybirdzls self-assigned this Dec 29, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants