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

[BUG] /chaosmonkey/assaults/runtime/attack does not respond when killApplicationActive is true #462

Open
blackr1234 opened this issue Apr 16, 2024 · 0 comments

Comments

@blackr1234
Copy link

blackr1234 commented Apr 16, 2024

Expected Behavior

Endpoint /chaosmonkey/assaults/runtime/attack should respond with 200 OK when killApplicationActive is set to true.


Current Behavior

There is no reply from the server, i.e. curl: (52) Empty reply from server when using cURL.


How to reproduce

Call below endpoints in order:

curl localhost:8080/actuator/chaosmonkey/assaults -X POST -d "{ \"killApplicationActive\": true }" -H "Content-Type: application/json"
curl localhost:8080/actuator/chaosmonkey/assaults/runtime/attack -X POST

Project details

  • Parent: spring-boot-starter-parent 3.2.4
  • spring-boot-starter-web (managed version)
  • spring-boot-starter-actuator (managed version)
  • chaos-monkey-spring-boot 3.1.0

Root cause

  • In the KillAppAssault#attack method, it calls SpringApplication.exit(context, () -> 0) to shut down Spring Boot.
    • This line will block until Spring Boot completes shutdown.
  • Spring Boot will stop all active requests as part of the shutdown routine.
  • Since the shutdown is being commenced within a request, Spring Boot can't proceed.
    • In the case of a graceful shutdown, Spring Boot keeps waiting, and when the grace period ends, it terminates all requests if they are still around.
    • In the case of an immediate shutdown (default), Spring Boot immediately terminates all requests.
  • That's why the /chaosmonkey/assaults/runtime/attack request never responds when it needs to kill the app.

Additional reference

In addition, if we check how Spring Boot's own /actuator/shutdown is implemented, we can see that it uses a new thread to perform the shutdown (ConfigurableApplicationContext#close).

See: ShutdownEndpoint.java - line 49

@blackr1234 blackr1234 changed the title /chaosmonkey/assaults/runtime/attack does not respond with 200 OK when killApplicationActive is true [BUG] /chaosmonkey/assaults/runtime/attack does not respond when killApplicationActive is true Apr 16, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant