Skip to content

Add a PauseHandler for Eureka clients - #4606

Open
Akhil-1527 wants to merge 1 commit into
spring-cloud:mainfrom
Akhil-1527:gh-3841-eureka-pause-handler
Open

Akhil-1527 wants to merge 1 commit into
spring-cloud:mainfrom
Akhil-1527:gh-3841-eureka-pause-handler

Conversation

@Akhil-1527

Copy link
Copy Markdown

Closes #3841

Calling /actuator/pause on a Eureka client doesn't change anything in Eureka today, so the instance stays UP for other clients. As suggested in the issue, this adds a PauseHandler that sets the instance status to OUT_OF_SERVICE on pause and cancels that override on resume. It uses the same EurekaServiceRegistry.setStatus calls as the serviceregistry endpoint, so after resume the server shows the instance with its own status again on the next heartbeat.

The handler is only created when spring-cloud-context is on the classpath, auto registration is enabled (same conditions as EurekaRegistration), and eureka.client.register-with-eureka isn't false. Without registration there's no status on the server to change, and setStatus would throw a NullPointerException because the client has no registration client, so /actuator/pause would fail.

There are unit tests for the handler and auto-configuration tests for when the bean is created. I also checked it end to end against an embedded Eureka server: after /actuator/pause the server reported OUT_OF_SERVICE, and after resuming it was back to UP after the next heartbeat. I added a short docs section as well.

One thing to note: /actuator/resume doesn't call PauseHandler.resume() at the moment (my end to end check called RestartEndpoint.doResume() directly). spring-cloud/spring-cloud-commons#1749 fixes that.

Calling /actuator/pause now sets the instance status to OUT_OF_SERVICE
in Eureka, and /actuator/resume cancels that override. The handler is
only created when spring-cloud-context is on the classpath, auto
registration is enabled and the instance registers with Eureka.

Fixes spring-cloudgh-3841

Signed-off-by: Akhil CH <200716675+Akhil-1527@users.noreply.github.com>

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

pause endpoint not work with spring cloud bus

2 participants