Repository navigation
feat(chart): probe the worker by default - #505
Conversation
Give the worker's container a readiness and a liveness probe that ping
the pod's own Celery worker through the broker (`celery inspect ping`
to `celery@${HOSTNAME}`), so that a rolling update keeps the old worker
pod until the new worker answers, and a worker that doesn't answer for
10 minutes is restarted. The probe uses Celery's default app with the
worker's `CELERY_BROKER_URL` instead of creating the proTES app, which
would connect to MongoDB and cost three times the CPU (measured on
kind: 0.4 vs 1.2 CPU seconds, 50 vs 110 MiB).
Helm merges values into the defaults, so rendering now fails with a
hint when a worker probe ends up with two handlers (e.g., `tcpSocket`
added to the default `exec`). Document the probes in the chart's README
and the upgrade notes.
Closes #504
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Rendering now also fails when a worker probe is left without a handler (e.g., only `exec: null`), which Kubernetes refuses at apply time. Test empty probes (the former defaults), command overrides and all handler types. Document the steady cost of the probes, the broker connections and the effect of broker outages on `helm upgrade --wait`. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Reviewer's GuideConfigurationAdd default Celery broker-backed worker readiness and liveness probes, and validate that each configured probe has exactly one handler.
DocumentationExplain the default worker probes, their operational effects and limitations, and how to configure them during upgrades.
TestsTest default probe behavior, overrides and disabling, plus rendering errors for probes with missing or multiple handlers.
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## dev #505 +/- ##
=========================================
Coverage 100.00% 100.00%
=========================================
Files 37 37
Lines 3475 3475
=========================================
Hits 3475 3475 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
Linked issuesChecked at commit e4cd618 #504 feat(chart): probe the worker by default · 4 of 5 met · 1 to check by hand
|
There was a problem hiding this comment.
Hey - I've found 2 issues
Prompt for AI Agents
Please address the comments from this code review:
## Individual Comments
### Comment 1
<location path="deployment/values.yaml" line_range="509" />
<code_context>
+ command:
+ - sh
+ - -c
+ - exec celery inspect ping --destination "celery@${HOSTNAME}" --timeout 10
+ initialDelaySeconds: 10
+ periodSeconds: 30
</code_context>
<issue_to_address>
**Unsupported brokers stay unready**
When the external broker uses a Celery transport without remote-control support, such as SQS, celery transports without remote-control support cannot answer `inspect ping`, so the readiness probe keeps the worker unready and the liveness probe eventually restarts it even when the worker can process tasks; deployments using those brokers fail to become healthy.
Document the remote-control transport requirement and provide a way to disable or replace both default probes for unsupported transports.
Also at `deployment/values.yaml:519`.
</issue_to_address>
### Comment 2
<location path="deployment/values.yaml" line_range="504-513" />
<code_context>
+ # periods and timeouts. Helm merges values into these: set a probe to
+ # `null` for none, and its `exec` to `null` for another type of probe
+ # (e.g., `tcpSocket`)
+ readinessProbe:
+ exec:
+ command:
+ - sh
+ - -c
+ - exec celery inspect ping --destination "celery@${HOSTNAME}" --timeout 10
+ initialDelaySeconds: 10
+ periodSeconds: 30
+ timeoutSeconds: 30
+ failureThreshold: 3
+ livenessProbe:
+ exec:
</code_context>
<issue_to_address>
**Empty probes stay enabled**
When a chart consumer sets an empty worker probe to disable it, relying on the schema description, `worker.readinessProbe: {}` inherits the new default `exec` probe, so consumers following the published schema's “none if empty” description get broker checks instead of disabling the probe.
Update the published schema descriptions to explain that empty probe values inherit the defaults and that `null` disables a worker probe.
</issue_to_address>Sourcery assessment
Needs a human reviewer. 2 findings to address first, and if the broker is unreachable for long enough, the new liveness probe restarts worker pods even though restarting them cannot restore broker access; this can interrupt in-flight task processing across the deployment. Reverting prevents future probe-triggered restarts, but cannot undo work already interrupted.
Blocking findings: deployment/values.yaml:509, deployment/values.yaml:513
The worker probes ping through Celery's remote control, which some transports (e.g., Amazon SQS) lack: say so, and how to turn the probes off or replace them, in the values, the chart's README and the upgrade notes. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Summary
The worker's container now has a readiness and a liveness probe by default, so that a rolling update keeps the old worker pod until the new worker answers, and a worker that stops answering is restarted:
execprobes:sh -c 'exec celery inspect ping --destination "celery@${HOSTNAME}" --timeout 10', which pings the pod's own worker (Celery's default node name iscelery@<hostname>, the pod's name) through the broker.maxUnavailable: 25%rounds down to 0, so the old pod stays until the new one is ready.nullturns a probe off;exec: nulllets you use another handler. A new check (protes.checkWorkerProbes) makes rendering fail with a hint when a probe ends up with two handlers (e.g.,tcpSocketmerged into the defaultexec) or none (onlyexec: null), both of which Kubernetes would refuse.Changed from the README's earlier suggestion: the probe doesn't use
--app pro_tes.celery_worker. Creating the proTES app connects to MongoDB, checks its indexes on every run, and costs about 3 times as much. The probe uses Celery's default app with the worker'sCELERY_BROKER_URL, which the chart always sets. FOCA's Celery factory sets nothing besides the broker URL and the result backend, and the ping doesn't need the result backend. Measured on kind in the worker container (200m CPU limit):Startup probe: the issue mentions
worker.startupProbeas an option. The library chart foca-common 0.4.0 only rendersworker.readinessProbeandworker.livenessProbe, so this PR doesn't add one. The liveness probe'sinitialDelaySecondsgives the worker time to start instead. Also,values.schema.jsonmust stay identical to the library's, so its descriptions ("none if empty") still describe the old defaults. Both belong in foca-common (see Open questions).Verification
pytest tests/test_chart.py: 215 passed. The new tests aretest_worker_probes,test_worker_liveness_tolerates_outages,test_worker_probe_disabled,test_worker_probe_override,test_worker_probe_empty_is_default,test_worker_probe_command_override,test_worker_probe_no_handlerandtest_worker_probe_two_handlers(for all three other handler types). Each runs for both probes. The first set failed before the change (7 failed, 2 passed).pytest(first commit): 2109 passed, 11 skipped.helm lint --strictwith the three CI value sets: all passed.pre-commit runon the changed files: all hooks passed. With--all-files, the semgrep hook exits 2 locally without output, also on files this PR doesn't touch, so it looks like an environment problem; CI runs it.mkdocs build --strict: passed.elixircloud/protes:dev, chart defaults with synthetic test Secrets), scriptkind-check.shin the work folder (not in the repo, which has no install test level):helm upgrade --install --wait: the worker became ready with the default probes (ping answered in ~2 s).command: [sleep, 3600]): after 90 s the new pod was0/1 Running, the old worker pod was still1/1 Running, and the rollout was stalled.rollout undorestored it.runAsUser: 1000700000,runAsGroup: 0, read-only root file system): the worker became ready, 0 restarts.HOSTNAME). CI on 749135f:CI passed(run 44265343179);Integration (TESK)skipped, as it is not part of the gate on this event.Review
Full lane (Helm chart). One round of
adversarial-reviewerandquality-reviewer, with no high findings. The quality reviewer raised two medium findings: the schema descriptions, which are left to the library (see below), and missing tests for{}andexec.commandoverrides, which were added. The fixes are in the second commit: a check for probes without a handler, tests for{}, command overrides and all handler types, and docs on the steady cost (about 1 CPU second per minute and pod), the broker connections, and--waitduring broker outages. No second round, as the only logic change is the small, tested "no handler" branch of the new check.Declined review findings
values.schema.jsonmust equal the library's (test_schema_of_library), so they change in foca-common. A follow-up issue is drafted.Open questions
None for this PR. Follow-up for foca-common (draft, not posted): render
worker.startupProbe, and update the schema descriptions of the worker probes.Closes #504
🤖 Generated with Claude Code
Summary by Sourcery
Probe worker responsiveness through Celery by default to make deployments safer and recover stalled workers automatically.
New Features:
Enhancements:
Documentation:
Tests: