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

CRaC restoration fails when Actuator's running on a separate port #38502

Closed
sdeleuze opened this issue Nov 22, 2023 · 2 comments
Closed

CRaC restoration fails when Actuator's running on a separate port #38502

sdeleuze opened this issue Nov 22, 2023 · 2 comments
Assignees
Labels
type: bug A general bug
Milestone

Comments

@sdeleuze
Copy link
Contributor

As reported originally on sdeleuze/spring-boot-crac-demo#3, restoration with spring-boot-starter-actuator is fine with the default configuration but fails with a custom management port.

To reproduce:

@wilkinsona
Copy link
Member

wilkinsona commented Nov 22, 2023

This can be reproduced with spring-boot-smoke-test-actuator by stopping and starting the context:

public static void main(String[] args) {
	SpringApplication application = new SpringApplication(SampleActuatorApplication.class);
	application.setApplicationStartup(new BufferingApplicationStartup(1024));
	ConfigurableApplicationContext context = application.run(args);
	context.stop();
	context.start();
}

Resulting failure:

Exception in thread "main" org.springframework.context.ApplicationContextException: Failed to start bean 'webServerStartStop'
	at org.springframework.context.support.DefaultLifecycleProcessor.doStart(DefaultLifecycleProcessor.java:287)
	at org.springframework.context.support.DefaultLifecycleProcessor$LifecycleGroup.start(DefaultLifecycleProcessor.java:467)
	at java.base/java.lang.Iterable.forEach(Iterable.java:75)
	at org.springframework.context.support.DefaultLifecycleProcessor.startBeans(DefaultLifecycleProcessor.java:256)
	at org.springframework.context.support.DefaultLifecycleProcessor.start(DefaultLifecycleProcessor.java:170)
	at org.springframework.context.support.AbstractApplicationContext.start(AbstractApplicationContext.java:1459)
	at smoketest.actuator.SampleActuatorApplication.main(SampleActuatorApplication.java:67)
Caused by: org.springframework.context.ApplicationContextException: Failed to start bean 'webServerStartStop'
	at org.springframework.context.support.DefaultLifecycleProcessor.doStart(DefaultLifecycleProcessor.java:287)
	at org.springframework.context.support.DefaultLifecycleProcessor$LifecycleGroup.start(DefaultLifecycleProcessor.java:467)
	at java.base/java.lang.Iterable.forEach(Iterable.java:75)
	at org.springframework.context.support.DefaultLifecycleProcessor.startBeans(DefaultLifecycleProcessor.java:256)
	at org.springframework.context.support.DefaultLifecycleProcessor.onRefresh(DefaultLifecycleProcessor.java:201)
	at org.springframework.context.support.AbstractApplicationContext.finishRefresh(AbstractApplicationContext.java:965)
	at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:619)
	at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.refresh(ServletWebServerApplicationContext.java:146)
	at org.springframework.boot.actuate.autoconfigure.web.server.ChildManagementContextInitializer.onApplicationEvent(ChildManagementContextInitializer.java:86)
	at org.springframework.boot.actuate.autoconfigure.web.server.ChildManagementContextInitializer.onApplicationEvent(ChildManagementContextInitializer.java:1)
	at org.springframework.context.event.SimpleApplicationEventMulticaster.doInvokeListener(SimpleApplicationEventMulticaster.java:178)
	at org.springframework.context.event.SimpleApplicationEventMulticaster.invokeListener(SimpleApplicationEventMulticaster.java:171)
	at org.springframework.context.event.SimpleApplicationEventMulticaster.multicastEvent(SimpleApplicationEventMulticaster.java:149)
	at org.springframework.context.support.AbstractApplicationContext.publishEvent(AbstractApplicationContext.java:445)
	at org.springframework.context.support.AbstractApplicationContext.publishEvent(AbstractApplicationContext.java:378)
	at org.springframework.boot.web.servlet.context.WebServerStartStopLifecycle.start(WebServerStartStopLifecycle.java:47)
	at org.springframework.context.support.DefaultLifecycleProcessor.doStart(DefaultLifecycleProcessor.java:284)
	... 6 more
Caused by: org.springframework.boot.web.server.PortInUseException: Port 8888 is already in use
	at org.springframework.boot.web.server.PortInUseException.lambda$0(PortInUseException.java:70)
	at org.springframework.boot.web.server.PortInUseException.lambda$1(PortInUseException.java:85)
	at org.springframework.boot.web.server.PortInUseException.ifCausedBy(PortInUseException.java:103)
	at org.springframework.boot.web.server.PortInUseException.ifPortBindingException(PortInUseException.java:82)
	at org.springframework.boot.web.server.PortInUseException.throwIfPortBindingException(PortInUseException.java:69)
	at org.springframework.boot.web.embedded.tomcat.TomcatWebServer.start(TomcatWebServer.java:228)
	at org.springframework.boot.web.servlet.context.WebServerStartStopLifecycle.start(WebServerStartStopLifecycle.java:44)
	at org.springframework.context.support.DefaultLifecycleProcessor.doStart(DefaultLifecycleProcessor.java:284)
	... 22 more
Caused by: java.lang.IllegalArgumentException: standardService.connector.startFailed
	at org.apache.catalina.core.StandardService.addConnector(StandardService.java:235)
	at org.springframework.boot.web.embedded.tomcat.TomcatWebServer.addPreviouslyRemovedConnectors(TomcatWebServer.java:286)
	at org.springframework.boot.web.embedded.tomcat.TomcatWebServer.start(TomcatWebServer.java:214)
	... 24 more
Caused by: org.apache.catalina.LifecycleException: Protocol handler start failed
	at org.apache.catalina.connector.Connector.startInternal(Connector.java:1046)
	at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:171)
	at org.apache.catalina.core.StandardService.addConnector(StandardService.java:232)
	... 26 more
Caused by: java.net.BindException: Address already in use
	at java.base/sun.nio.ch.Net.bind0(Native Method)
	at java.base/sun.nio.ch.Net.bind(Net.java:555)
	at java.base/sun.nio.ch.ServerSocketChannelImpl.netBind(ServerSocketChannelImpl.java:337)
	at java.base/sun.nio.ch.ServerSocketChannelImpl.bind(ServerSocketChannelImpl.java:294)
	at org.apache.tomcat.util.net.NioEndpoint.initServerSocket(NioEndpoint.java:247)
	at org.apache.tomcat.util.net.NioEndpoint.bind(NioEndpoint.java:202)
	at org.apache.tomcat.util.net.AbstractEndpoint.bindWithCleanup(AbstractEndpoint.java:1280)
	at org.apache.tomcat.util.net.AbstractEndpoint.start(AbstractEndpoint.java:1366)
	at org.apache.coyote.AbstractProtocol.start(AbstractProtocol.java:635)
	at org.apache.catalina.connector.Connector.startInternal(Connector.java:1043)
	... 28 more

The restart of the main web server causes the management context, including its web server, to be refreshed again.

@wilkinsona wilkinsona changed the title CRaC restoration fails with a custom management port CRaC restoration fails when Actuator's running on a separate port Nov 22, 2023
@wilkinsona wilkinsona added type: bug A general bug and removed status: waiting-for-triage An issue we've not yet triaged labels Nov 22, 2023
@wilkinsona wilkinsona added this to the 3.2.x milestone Nov 22, 2023
@wilkinsona wilkinsona self-assigned this Nov 22, 2023
@wilkinsona wilkinsona modified the milestones: 3.2.x, 3.2.0 Nov 22, 2023
@sdeleuze
Copy link
Contributor Author

Thanks for the quick fix @wilkinsona, I confirm this fixes the issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: bug A general bug
Projects
None yet
Development

No branches or pull requests

3 participants