feat(health): add VelocityHealthCheck for K8s readiness probe (#35602)#35771
feat(health): add VelocityHealthCheck for K8s readiness probe (#35602)#35771dsolistorres wants to merge 1 commit into
Conversation
Adds a readiness-only health check that verifies the Velocity engine's global macro library is registered by evaluating "#renderMarks(\$null)" through VelocityUtil.getEngine() and detecting the literal directive marker in the output. When the macro library failed to load (see spike #35329), the engine reports init success while every public page renders macros as literal text; this check surfaces that state through /readyz so K8s can stop routing traffic. isLivenessCheck() returns false — a one-time init failure should remove the pod from the load balancer, not trigger a restart loop. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
|
Claude finished @dsolistorres's task in 4m 28s —— View job 🔍 dotCMS Backend Review
Result✅ All four reviewers returned
Note on formal reviewI was unable to submit a formal |
|
✅ dotCMS Backend Review: no issues found. |
|
Heads up — the intermittent Postman failures in
|
Summary
Closes #35602 (follow-up implementation from spike #35329, companion to #35601 / #35768).
Adds a readiness-only health check that verifies the Velocity engine's global macro library is registered. When the library failed to load (see spike #35329),
engine.init()can return successfully while every public page renders#renderMarks/#editContentletas literal text. This check surfaces that state through/readyzso K8s can stop routing traffic to the affected pod.Defense-in-depth alongside the fail-loud flag in #35601: that flag handles the common case (init throws → existing
ServletContainerHealthCheckgates traffic viadotcms.started.up). This check covers the opt-out case (velocimacro.library.fail-on-missing=false) and any future post-init macro-registry corruption.Changes
VelocityHealthCheck(new) —com.dotcms.health.checks.cdi.VelocityHealthCheckextendsHealthCheckBase. Evaluates the probe#renderMarks($null)throughVelocityUtil.getEngine()and returns DOWN when the rendered output contains the literal#renderMarks(marker.CoreHealthCheckProvider— register the new check alongside the existing CDI checks (database, cache, elasticsearch).VelocityHealthCheckTest(new) — three unit tests covering the UP path, the literal-rendering DOWN path, and a propagated-exception DOWN path.Design notes
isLivenessCheck()returns false — a one-time init failure should remove the pod from the load balancer, not trigger a restart loop.isReadinessCheck()returns true.getOrder()returns 110 — runs after database (default 100), cache (30), and elasticsearch (40).Test plan
VelocityHealthCheckTest— 3/3 pass:VelocityUtil.getEngine()throwsjust dev-run, thenGET /dotmgt/health:{ "name": "velocity", "status": "UP", "durationMs": 0, "message": "Velocity macro library registered (#renderMarks resolved) [0ms]", "monitorModeApplied": false }🤖 Generated with Claude Code