Skip to content

fix(chart): add probes to the API Deployment - #254

Merged
uniqueg merged 3 commits into
devfrom
fix/chart-probes
Nov 7, 2026
Merged

uniqueg merged 3 commits into
devfrom
fix/chart-probes

Conversation

@uniqueg

@uniqueg uniqueg commented Nov 7, 2026 •

Copy link
Copy Markdown
Member

Summary

Adds startup, readiness and liveness probes to the tesk-api Deployment, so that helm install --wait returns only once the API answers (before, it returned about a minute earlier, and the Ingress answered 502).

  • The probes request GET <ingress.path><tesApiBasePath>/service-info (served from a local file, no backend). With auth.mode: auth and auth.serviceInfoPublic: false, that needs a token, so they check the port instead.
  • Configurable with tesk.startupProbe, tesk.readinessProbe and tesk.livenessProbe (the chart's API values live under tesk, not api): Kubernetes probe fields merged with defaults, enabled: false to leave one out. Defaults live in the tesk.probe template so they also apply with --reuse-values. Startup allows 5 minutes.
  • Selectors and names are unchanged.
  • Docs: configuration reference, upgrade notes, MicroK8s guide (install with --wait, polling kept as a fallback).

Closes #253

Verification

  • uv run pytest tests: 298 passed (new test_probes_*, written first and failing before the change; legacy comparisons strip probes).
  • ruff check, ruff format --check, mypy: clean.
  • Throwaway Minikube profile (own home and kubeconfig, deleted afterwards): with the chart from dev, helm install --wait returned 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

  • Refactor of the tesk.probe helper: the logic is covered by tests; left as is.
  • tesk.port null renders port 0 in the probes: the Service, Ingress and containerPort already fail on a null port.
  • Liveness timing (5 s timeout, 3 failures at 20 s) is a tuning choice, overridable.
  • Commit type 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:

  • Add configurable startup, readiness, and liveness probes to the API Deployment, with defaults that verify API availability and support authentication-aware checks.

Bug Fixes:

  • Ensure Helm installs and upgrades wait until the API is ready, preventing premature Ingress 502 responses.

Enhancements:

  • Allow individual probes to be disabled and customized while preserving existing deployment selectors and names.

Documentation:

  • Document probe configuration, startup timing, upgrade behavior, and updated MicroK8s installation guidance.

Tests:

  • Add comprehensive Helm rendering coverage for probe defaults, overrides, authentication behavior, disabling, paths, ports, schemas, and reuse-values compatibility.

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

sourcery-ai Bot commented Nov 7, 2026 •

Copy link
Copy Markdown
Contributor

Reviewer's Guide

API

Define the supported probe configuration shape so invalid probe values are rejected.

  • charts/tesk/values.schema.json L191-211

Implementation

Implement the probe defaults, authentication-aware action selection, path construction, and merging, then attach the resulting probes to the API container.

  • charts/tesk/templates/_helpers.tpl L155-204
  • charts/tesk/templates/common/tesk-deployment.yaml L153-157

Configuration

Expose the three probes as chart values and explain their defaults, including that the defaults are applied in templates for reuse-values upgrades.

  • charts/tesk/values.yaml L60-78

Documentation

Document probe configuration and behavior, upgrade implications, and how the MicroK8s guide waits for and verifies API readiness.

  • docs/configuration.md L49-89
  • docs/microk8s.md L89, L106-116
  • docs/upgrading.md L12-22

Tests

Cover rendered probe defaults, overrides, custom actions, auth-dependent behavior, disabling, path and port handling, schema validation, reuse-values, and legacy compatibility.

  • tests/helm.py L129-148
  • tests/test_chart.py L381-580 (+3 small edits)

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

@codecov

codecov Bot commented Nov 7, 2026 •

Copy link
Copy Markdown

Codecov Report

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

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.
📢 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 7, 2026 08:13

@sourcery-ai sourcery-ai Bot left a comment

Copy link
Copy Markdown
Contributor

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="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


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

Comment thread charts/tesk/templates/_helpers.tpl Resolved
Comment thread charts/tesk/templates/_helpers.tpl Resolved
A tesApiBasePath ending in a slash gave //service-info.

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
@uniqueg
uniqueg merged commit 3647c20 into dev Nov 7, 2026
21 checks passed
@uniqueg
uniqueg deleted the fix/chart-probes branch November 7, 2026 08:20
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.

fix(chart): add probes to the API Deployment

1 participant