Commit 3beafd9
authored
fix(serve): publish availability events so /actuator/health returns 200 (#46)
Problem: /actuator/health on a running `code-iq serve` returned HTTP 503
with body {"groups":["liveness","readiness"],"status":"OUT_OF_SERVICE"},
even after the graph was fully loaded and /api/stats was returning real
data. This made the health endpoint unusable for K8s/Compose readiness
probes and confused baseline smoke-tests.
Root cause: ServeCommand.call() blocks on Thread.currentThread().join()
inside Spring Boot's CommandLineRunner.run(). Because the runner never
returns, Spring's ApplicationReadyEvent is never published, and neither
is the default AvailabilityChangeEvent that normally transitions
ReadinessState from REFUSING_TRAFFIC to ACCEPTING_TRAFFIC. With the
serving profile's probes enabled, the aggregated health endpoint stays
pinned at OUT_OF_SERVICE forever.
Fix: ServeCommand now explicitly publishes the two availability events
via a new markReady() method before blocking:
AvailabilityChangeEvent.publish(events, this, LivenessState.CORRECT);
AvailabilityChangeEvent.publish(events, this, ReadinessState.ACCEPTING_TRAFFIC);
markReady() is extracted for testability. A new ServeCommandTest case
verifies both events are published in the documented order.
Verified end-to-end against both seed repos via the updated pipeline
script: /actuator/health now returns HTTP 200 with status "UP".
| seed | ready | health_http | before |
|---------------------|-------:|------------:|-------:|
| spring-petclinic | 13s | 200 | 503 |
| realworld-express | 14s | 200 | 503 |
Follow-up (out of scope): GraphBootstrapper's
@eventlistener(ApplicationReadyEvent.class) is effectively dead code
for the same reason — the listener never fires because the event never
fires. Only not-a-bug today because enrich always runs before serve in
our pipeline, so the bootstrap fallback never actually needs to trigger.1 parent 62806c4 commit 3beafd9
3 files changed
Lines changed: 57 additions & 0 deletions
File tree
- docs/superpowers/baselines/2026-04-17
- src
- main/java/io/github/randomcodespace/iq/cli
- test/java/io/github/randomcodespace/iq/cli
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
237 | 237 | | |
238 | 238 | | |
239 | 239 | | |
| 240 | + | |
240 | 241 | | |
241 | 242 | | |
242 | 243 | | |
| |||
Lines changed: 26 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
5 | 5 | | |
6 | 6 | | |
7 | 7 | | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
8 | 12 | | |
9 | 13 | | |
10 | 14 | | |
| |||
56 | 60 | | |
57 | 61 | | |
58 | 62 | | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
59 | 66 | | |
60 | 67 | | |
61 | 68 | | |
| |||
96 | 103 | | |
97 | 104 | | |
98 | 105 | | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
99 | 116 | | |
100 | 117 | | |
101 | 118 | | |
| |||
105 | 122 | | |
106 | 123 | | |
107 | 124 | | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
108 | 134 | | |
109 | 135 | | |
110 | 136 | | |
| |||
Lines changed: 30 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
3 | 3 | | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
4 | 11 | | |
5 | 12 | | |
6 | 13 | | |
7 | 14 | | |
8 | 15 | | |
9 | 16 | | |
| 17 | + | |
| 18 | + | |
10 | 19 | | |
11 | 20 | | |
12 | 21 | | |
| |||
76 | 85 | | |
77 | 86 | | |
78 | 87 | | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
79 | 109 | | |
0 commit comments