Repository navigation
fix(chart): add probes to the API Deployment - #254
Conversation
The API container had no probes, so helm install --wait returned about a minute before the API answered, and the Ingress answered 502 until then. Add startup, readiness and liveness probes that request the service info (a local file, no backend), or check the port if the endpoint needs a token. They are configurable with tesk.startupProbe, tesk.readinessProbe and tesk.livenessProbe. Selectors and names are unchanged. Closes #253 Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
Pin the default probe timings, test null, string and partial actions, and document that httpGet fields are merged with the default request, plus the 5 minute startup budget. Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
Reviewer's GuideAPIDefine the supported probe configuration shape so invalid probe values are rejected.
ImplementationImplement the probe defaults, authentication-aware action selection, path construction, and merging, then attach the resulting probes to the API container.
ConfigurationExpose the three probes as chart values and explain their defaults, including that the defaults are applied in templates for reuse-values upgrades.
DocumentationDocument probe configuration and behavior, upgrade implications, and how the MicroK8s guide waits for and verifies API readiness.
TestsCover rendered probe defaults, overrides, custom actions, auth-dependent behavior, disabling, path and port handling, schema validation, reuse-values, and legacy compatibility.
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 #254 +/- ##
=========================================
Coverage 100.00% 100.00%
=========================================
Files 1 1
Lines 229 229
=========================================
Hits 229 229 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
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="charts/tesk/templates/_helpers.tpl" line_range="188" />
<code_context>
+{{- $action := dict "path" (printf "%s%s/service-info" (trimSuffix "/" (toString $root.Values.ingress.path)) ((index .values "tesk.tesApiBasePath") | default "/ga4gh/tes/v1")) "port" $port -}}
+{{- if $needsToken -}}
+{{- $key = "tcpSocket" -}}
+{{- $action = dict "port" $port -}}
+{{- end -}}
+{{- $own := false -}}
</code_context>
<issue_to_address>
**Readiness can precede API readiness**
When `auth.mode` is `auth`, `auth.serviceInfoPublic` is `false`, and the port accepts connections before the API can serve requests, the `tcpSocket` probe succeeds as soon as the port accepts connections, even if the API cannot yet serve requests. Kubernetes can then mark the pod ready and send it traffic before the API is usable, so callers still see failed requests during startup.
Use a readiness check that verifies API readiness without requiring an external token, or document and provide a configurable readiness action for this mode.
</issue_to_address>
### Comment 2
<location path="charts/tesk/templates/_helpers.tpl" line_range="185" />
<code_context>
+{{- $port := $root.Values.tesk.port | int -}}
+{{- $needsToken := and (eq (toString $root.Values.auth.mode) "auth") (eq (lower (toString (index .values "auth.serviceInfoPublic"))) "false") -}}
+{{- $key := "httpGet" -}}
+{{- $action := dict "path" (printf "%s%s/service-info" (trimSuffix "/" (toString $root.Values.ingress.path)) ((index .values "tesk.tesApiBasePath") | default "/ga4gh/tes/v1")) "port" $port -}}
+{{- if $needsToken -}}
+{{- $key = "tcpSocket" -}}
</code_context>
<issue_to_address>
**Probe path does not match API route**
When `tesk.tesApiBasePath` ends in `/`, the helper appends `/service-info` to `tesk.tesApiBasePath` without trimming its trailing slash, so the generated `httpGet.path` contains `//service-info` and does not match the API route; the probes fail, leaving the pod unready and causing `helm install --wait` to time out.
Trim the trailing slash from `tesk.tesApiBasePath` before appending `/service-info`.
</issue_to_address>Linked issues
#253 fix(chart): add probes to the API Deployment · 7 of 8 met · 1 to check by hand
| # | Requirement | Status | Notes |
|---|---|---|---|
| 1 | Add startup, readiness and liveness probes to the API container. | ✅ Met | The Deployment template renders all three probes for the API container. |
| 2 | Probe GET <ingress.path>/service-info, or check the port when service info needs a token. | ✅ Met | The probe helper builds the configured service-info path and switches to a TCP check when auth is enabled and service info is private. |
| 3 | Make probes configurable with camelCase values and defaults that allow the slow start. | ✅ Met | The chart accepts the three tesk.*Probe values, merges user fields with defaults, supports disabling a probe, and gives startup up to 60 failures. |
| 4 | Keep the selectors and names unchanged. | ✅ Met | The Deployment wiring leaves these unchanged, and a chart test checks the selector, labels and container name. |
| 5 | Test the probes with the chart tests. | ✅ Met | The added chart tests cover defaults, overrides, authentication, disabling, paths, ports, schema validation and reuse-values compatibility. |
| 6 | Verify helm install --wait on a throwaway cluster. | 👀 Check by hand (runtime) | Confirm on a throwaway cluster that installation with --wait returns only once service-info answers; the PR description reports a successful Minikube run. |
| 7 | Update the configuration reference. | ✅ Met | The configuration guide documents probe values, defaults, customization and authentication-aware behavior. |
| 8 | Update the MicroK8s guide. | ✅ Met | The guide now installs with --wait and retains polling as a fallback. |
Sourcery assessment
Needs a human reviewer. 2 findings to address first, and if the probe path or timing is wrong, readiness can remove API pods from service and liveness can repeatedly restart them; a startup taking over five minutes is restarted by default. Reverting stops the probes from causing further disruption, but it cannot undo traffic interruptions that already occurred.
Blocking findings: charts/tesk/templates/_helpers.tpl:188, charts/tesk/templates/_helpers.tpl:185
A tesApiBasePath ending in a slash gave //service-info. Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
Summary
Adds startup, readiness and liveness probes to the
tesk-apiDeployment, so thathelm install --waitreturns only once the API answers (before, it returned about a minute earlier, and the Ingress answered 502).GET <ingress.path><tesApiBasePath>/service-info(served from a local file, no backend). Withauth.mode: authandauth.serviceInfoPublic: false, that needs a token, so they check the port instead.tesk.startupProbe,tesk.readinessProbeandtesk.livenessProbe(the chart's API values live undertesk, notapi): Kubernetes probe fields merged with defaults,enabled: falseto leave one out. Defaults live in thetesk.probetemplate so they also apply with--reuse-values. Startup allows 5 minutes.--wait, polling kept as a fallback).Closes #253
Verification
uv run pytest tests: 298 passed (newtest_probes_*, written first and failing before the change; legacy comparisons strip probes).ruff check,ruff format --check,mypy: clean.dev,helm install --waitreturned after 14 s and service-info was refused (connection refused); with this chart it returned after 38 s and service-info answered at once.mkdocs build --strict: could not run locally (the sandbox blocks the tesk-api source download); CI runs it.Review
Full review (Helm chart): adversarial-reviewer found nothing medium or high; quality-reviewer's medium findings were handled (merge behaviour documented and tested, exact default timings pinned, upgrade note on the startup budget).
Declined review findings
tesk.probehelper: the logic is covered by tests; left as is.tesk.portnull renders port 0 in the probes: the Service, Ingress andcontainerPortalready fail on a null port.fix(chart): kept, as the issue defines it.🤖 Generated with Claude Code
Summary by Sourcery
Add health probes to the API Deployment so Kubernetes and Helm wait for the API to become available before routing traffic.
New Features:
Bug Fixes:
Enhancements:
Documentation:
Tests: