Call PauseHandler resume from the resume endpoint - #1749
Akhil-1527 wants to merge 2 commits into
Conversation
The resume endpoint only called doResume() when the context was not running. The pause endpoint no longer stops the context, so /actuator/resume never reached the PauseHandler beans after /actuator/pause. Track the paused state and resume when it is set. Signed-off-by: Akhil CH <200716675+Akhil-1527@users.noreply.github.com>
|
After pause then Checked on this branch with a test The stale list predates this PR, but re-collecting |
|
As @kdelay points out we should handle the pause then restart case properly |
After /actuator/pause then /actuator/restart the endpoint kept paused = true and still held the PauseHandler beans of the closed context. Clear both when the context closes and collect the handlers again from the new context. Signed-off-by: Akhil CH <200716675+Akhil-1527@users.noreply.github.com>
|
Thanks @kdelay, good catch. I pushed a commit for it: |
| for (PauseHandler handler : this.pauseHandlers) { | ||
| handler.pause(); | ||
| } | ||
| this.paused = true; |
There was a problem hiding this comment.
I think we should only set this to true if !this.pauseHandlers.isEmpty(). Otherwise /actuator/resume will return true when nothing was paused
/actuator/resumenever callsresume()on thePauseHandlerbeans.ResumeEndpoint.resume()only callsdoResume()when the context is not running. That made sense when pause stopped the context, but since 7287a3c the pause endpoint calls thePauseHandlerbeans and the context keeps running. So after/actuator/pause,/actuator/resumereturns false and does nothing, and anything paused throughIntegrationPauseHandlerstays paused.This change tracks the paused state in
RestartEndpointand resumes when it is set. Resume still returns false when nothing was paused.I added a test in
RestartIntegrationTeststhat pauses and resumes with a testPauseHandler(it fails without the fix), and updated the docs line for these two endpoints, which still described the oldLifecyclebehavior.I ran into this while adding a Eureka
PauseHandlerfor spring-cloud/spring-cloud-netflix#3841, which needs/actuator/resumeto work.