Add a PauseHandler for Eureka clients - #4606
Open
Akhil-1527 wants to merge 1 commit into
Open
Akhil-1527 wants to merge 1 commit into
Akhil-1527 wants to merge 1 commit into
Conversation
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #3841
Calling
/actuator/pauseon a Eureka client doesn't change anything in Eureka today, so the instance staysUPfor other clients. As suggested in the issue, this adds aPauseHandlerthat sets the instance status toOUT_OF_SERVICEon pause and cancels that override on resume. It uses the sameEurekaServiceRegistry.setStatuscalls as theserviceregistryendpoint, 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-contextis on the classpath, auto registration is enabled (same conditions asEurekaRegistration), andeureka.client.register-with-eurekaisn't false. Without registration there's no status on the server to change, andsetStatuswould throw aNullPointerExceptionbecause the client has no registration client, so/actuator/pausewould 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/pausethe server reportedOUT_OF_SERVICE, and after resuming it was back toUPafter the next heartbeat. I added a short docs section as well.One thing to note:
/actuator/resumedoesn't callPauseHandler.resume()at the moment (my end to end check calledRestartEndpoint.doResume()directly). spring-cloud/spring-cloud-commons#1749 fixes that.