Skip to content

feat(ledger): add liveness/readiness probes and graceful shutdown - #144

Merged
tiana-code merged 3 commits into
mainfrom
feat/E-01-probes-shutdown
Jun 16, 2026
Merged

feat(ledger): add liveness/readiness probes and graceful shutdown#144
tiana-code merged 3 commits into
mainfrom
feat/E-01-probes-shutdown

Conversation

@tiana-code

Copy link
Copy Markdown
Owner

What

Adds Kubernetes-grade health signals and graceful shutdown to the ledger service. Config-only, no domain/schema change.

  • Liveness (/actuator/health/liveness) reports JVM state only. A database outage drains traffic, it never restarts the pod (avoids a shared-DB restart storm).
  • Readiness (/actuator/health/readiness) aggregates readinessState + db + liquibase, so traffic is not routed before connectivity and migrations are ready.
  • Probe bodies expose component name + status (show-components: always) but not internals (show-details: never), safe for the unauthenticated /actuator/health/** paths.
  • In the prod profile only, Actuator binds to a dedicated management port (9090), off the public 8080 port.
  • Graceful shutdown: server.shutdown=graceful with a 30s drain window; a structured INFO event is logged when the shutdown phase begins.

SecurityConfig and actuator exposure are unchanged (/actuator/health/** was already public).

Tests

AC Test
AC-1 liveness 200 HealthProbesIT
AC-2 readiness 200 (db+liquibase UP) HealthProbesIT
AC-3 readiness 503 on DB down ReadinessDownIT (own container)
AC-4 prod management port != app port ManagementPortPropertiesTest
AC-5 liveness has no db component HealthProbesIT
AC-6 graceful shutdown + 30s drain bound ManagementPortPropertiesTest
AC-7 in-flight request completes on shutdown GracefulDrainIT
AC-8 one structured INFO shutdown event GracefulShutdownLoggerTest + GracefulDrainIT
AC-9 aggregate health still 200 HealthProbesIT

Integration tests run on CI (no Docker locally). Unit tests, detekt, spotless, assemble green locally.

Closes #64
Closes #65

@tanya_r added 3 commits June 16, 2026 10:21
configure spring boot health probes with a liveness group (jvm state only)
and a readiness group aggregating db and liquibase, so a database outage
drains traffic instead of restarting pods. expose component status without
details on the public probe endpoints, and move actuator to a dedicated
management port in the prod profile. enable graceful shutdown with a 30s
drain window and emit a structured info event when the shutdown phase begins.

Closes #64
Closes #65
spring boot 3.4+ validates health group membership at startup and fails the context when a referenced contributor is absent. disable strict validation so the readiness group degrades gracefully across environments; the probe integration tests still assert db and liquibase are present and up at runtime.
…aceful test

the liquibase health contributor is not registered in every context, so the readiness group references readinessState and db only; a failed migration aborts startup before the server binds, so connectivity is the sufficient readiness signal. the graceful-drain test now calls webServer.shutDownGracefully instead of closing the spring test context, which avoided a double-close against @DirtiesContext.
@tiana-code
tiana-code merged commit 5764441 into main Jun 16, 2026
7 checks passed
@tiana-code
tiana-code deleted the feat/E-01-probes-shutdown branch June 16, 2026 13:48
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

Successfully merging this pull request may close these issues.

Add graceful shutdown Add liveness and readiness probes

1 participant