Skip to content

feat(chart): probe the worker by default - #505

Merged
uniqueg merged 3 commits into
devfrom
feat/504-worker-probes
Nov 18, 2026
Merged

uniqueg merged 3 commits into
devfrom
feat/504-worker-probes

Conversation

@uniqueg

@uniqueg uniqueg commented Nov 18, 2026 •

Copy link
Copy Markdown
Member

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:

  • Both are exec probes: sh -c 'exec celery inspect ping --destination "celery@${HOSTNAME}" --timeout 10', which pings the pod's own worker (Celery's default node name is celery@<hostname>, the pod's name) through the broker.
  • Readiness: every 30 s (first after 10 s), timeout 30 s, 3 failures. With 1 replica, the worker Deployment's maxUnavailable: 25% rounds down to 0, so the old pod stays until the new one is ready.
  • Liveness: first after 60 s, every 120 s, timeout 30 s, 5 failures: restart only after about 10 minutes without an answer (so a short broker outage doesn't restart the worker).
  • Helm merges values into these defaults. null turns a probe off; exec: null lets 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., tcpSocket merged into the default exec) or none (only exec: null), both of which Kubernetes would refuse.
  • Docs: the chart README's "Probes" section and the 0.7.0 upgrade notes (what changes and what to check in existing values).

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's CELERY_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):

probe                         wall   CPU     max RSS
--app pro_tes.celery_worker   6.3 s  1.18 s  108 MiB
default app (this PR)         1.9 s  0.39 s   49 MiB

Startup probe: the issue mentions worker.startupProbe as an option. The library chart foca-common 0.4.0 only renders worker.readinessProbe and worker.livenessProbe, so this PR doesn't add one. The liveness probe's initialDelaySeconds gives the worker time to start instead. Also, values.schema.json must 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 are test_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_handler and test_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).
  • Full pytest (first commit): 2109 passed, 11 skipped.
  • helm lint --strict with the three CI value sets: all passed.
  • pre-commit run on 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.
  • kind (Kubernetes v1.37, kindnet with enforced NetworkPolicies, image elixircloud/protes:dev, chart defaults with synthetic test Secrets), script kind-check.sh in the work folder (not in the repo, which has no install test level):
    1. helm upgrade --install --wait: the worker became ready with the default probes (ping answered in ~2 s).
    2. A worker that starts but never serves (command: [sleep, 3600]): after 90 s the new pod was 0/1 Running, the old worker pod was still 1/1 Running, and the rollout was stalled. rollout undo restored it.
    3. The broker's NetworkPolicy is enforced: a pod without the worker's labels can't reach the broker, while the worker's probe can.
    4. OpenShift-like arbitrary UID (runAsUser: 1000700000, runAsGroup: 0, read-only root file system): the worker became ready, 0 restarts.
  • Not run: a real OpenShift cluster (CRI-O also sets 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-reviewer and quality-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 {} and exec.command overrides, 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 --wait during broker outages. No second round, as the only logic change is the small, tested "no handler" branch of the new check.

Declined review findings

  • Schema descriptions still say "none if empty" (medium, quality): values.schema.json must equal the library's (test_schema_of_library), so they change in foca-common. A follow-up issue is drafted.
  • Check also runs when the worker is disabled (low, quality): kept on purpose, so that the values stay valid when the worker is turned back on (stated in the helper's comment).
  • Longer readiness period once ready (low, adversarial): Kubernetes has no such setting; the cost is documented instead.

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:

  • Add default Celery-based readiness and liveness probes to the worker container so rollouts wait for a responsive worker and unresponsive workers are restarted.

Enhancements:

  • Support disabling or overriding worker probes while validating that each rendered probe has exactly one Kubernetes handler.
  • Document probe behavior, resource and broker considerations, upgrade impacts, and configuration requirements.

Documentation:

  • Document the new worker probe defaults and migration guidance for existing Helm values.

Tests:

  • Add chart tests covering default probes, overrides, disabling probes, outage tolerance, and invalid handler configurations.

uniqueg and others added 2 commits November 18, 2026 08:51
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]>
@sourcery-ai

sourcery-ai Bot commented Nov 18, 2026 •

Copy link
Copy Markdown

Reviewer's Guide

Configuration

Add default Celery broker-backed worker readiness and liveness probes, and validate that each configured probe has exactly one handler.

  • deployment/templates/_helpers.tpl L216-245
  • deployment/values.yaml L492-525

Documentation

Explain the default worker probes, their operational effects and limitations, and how to configure them during upgrades.

  • deployment/README.md L722-744
  • docs/upgrading.md L61-84

Tests

Test default probe behavior, overrides and disabling, plus rendering errors for probes with missing or multiple handlers.

  • tests/test_chart.py L415-518

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

@read-the-docs-community

read-the-docs-community Bot commented Nov 18, 2026 •

Copy link
Copy Markdown

Documentation build overview

📚 proTES | 🛠️ Build #35978405 | 📁 Comparing e4cd618 against latest (fa54993)

  🔍 Preview build  

2 files changed
± deployment/index.html
± upgrading/index.html

@codecov

codecov Bot commented Nov 18, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 100.00%. Comparing base (fa54993) to head (e4cd618).

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.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@uniqueg
uniqueg marked this pull request as ready for review November 18, 2026 08:23
@uniqueg uniqueg moved this from Backlog to In review in ELIXIR On-Cloud Nov 18, 2026
@sourcery-ai

sourcery-ai Bot commented Nov 18, 2026 •

Copy link
Copy Markdown

Linked issues

Checked at commit e4cd618

#504 feat(chart): probe the worker by default · 4 of 5 met · 1 to check by hand

# Requirement Status Notes
1 Default worker liveness and startup (or readiness) probes to ping the pod's own worker through the broker. ✅ Met The chart defaults to readiness and liveness exec probes targeting celery@${HOSTNAME} through Celery's default app and the worker's broker URL.
2 Check that the probes work with the broker's credentials and NetworkPolicies. ✅ Met The PR reports kind validation using synthetic Secrets and enforced NetworkPolicies.
3 Check that the probes work under OpenShift. 👀 Check by hand (runtime) Verify the probes on a real OpenShift cluster; the PR reports an OpenShift-like arbitrary-UID check in kind but says a real OpenShift cluster was not tested.
4 Keep the old worker pod running during a rolling update if the new worker does not start. ✅ Met The PR reports a kind rollout check where a worker that never served stayed unready, the old pod remained ready, and the rollout stalled.
5 Update the Probes section of the README and the upgrade notes. ✅ Met The chart README and upgrade notes document the default probes, their effects, and configuration changes.

@sourcery-ai sourcery-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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


Sourcery is free for open source - if you like our reviews please consider sharing them ✨

Comment thread deployment/values.yaml Resolved
Comment thread deployment/values.yaml Resolved
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]>

@sourcery-ai sourcery-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sourcery assessment

Approved.

@uniqueg
uniqueg merged commit 8314ccc into dev Nov 18, 2026
38 checks passed
@uniqueg
uniqueg deleted the feat/504-worker-probes branch November 18, 2026 08:41
@github-project-automation github-project-automation Bot moved this from In review to Done in ELIXIR On-Cloud Nov 18, 2026
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.

feat(chart): probe the worker by default

1 participant