Skip to content

feat: set the API's update strategy - #306

Merged
uniqueg merged 6 commits into
devfrom
feat/305-api-strategy
Nov 15, 2026
Merged

uniqueg merged 6 commits into
devfrom
feat/305-api-strategy

Conversation

@uniqueg

@uniqueg uniqueg commented Nov 15, 2026 •

Copy link
Copy Markdown
Member

Summary

Makes chart upgrades safe for the new upgrade order (TESK API first, then the taskmaster): tesk-api 2.0.0 (elixir-cloud-aai/tesk-api#183) selects executor jobs by taskmaster-name=<id>,job-type=executor, and the taskmaster of tesk-core 0.12.0 also labels the filer jobs with taskmaster-name (elixir-cloud-aai/tesk-core#147). An older API pod that serves tasks of the new taskmaster reports wrong states, and in this chart one helm upgrade switches the API and the taskmaster together.

  • New value tesk.strategy (the API Deployment's spec.strategy), default type: Recreate; type: RollingUpdate (with rollingUpdate) for operators who upgrade in two steps; null leaves Kubernetes' default, as charts up to 0.3.0 did.
  • values.schema.json closes the map (type enum, rollingUpdate.maxSurge/maxUnavailable int or string); the template fails on any rollingUpdate with Recreate, which Kubernetes rejects.
  • .github/actions/install-chart (CI and release): after the install, upgrade to Kubernetes' default strategy and back, and check that the Deployment ends up with {"type": "Recreate"}.
  • Docs: values.yaml, configuration reference, upgrade notes (why, the two-step alternative, and a one-time kubectl patch for server-side apply), deployment guide and chart README (downtime on every rollout).
  • Image versions and appVersion are left for the release-train PR after the tags.

Verification

  • helm lint charts/tesk --strict (Helm 3.22.1): passed.
  • REQUIRE_HELM=1 pytest (all tests, including tests/test_chart.py): 805 passed before the review fixes; after them, pytest tests/test_chart.py -k "strategy or schema": 73 passed. The new tests failed before the implementation.
  • pre-commit run --all-files: passed. mkdocs build --strict: passed.
  • kind (v0.33.0, by hand):
    • The new "Upgrade strategy" step of install-chart, run against a release: passed, ending with {"type":"Recreate"}.
    • Helm 3 upgrade from a release with Kubernetes' default (RollingUpdate, rollingUpdate 25%/25%) to the new default: works, as retainKeys drops rollingUpdate.
    • Server-side apply (kubectl apply --server-side of the rendered Deployment) of the same upgrade: fails with spec.strategy.rollingUpdate: Forbidden, also when rollingUpdate: null is rendered; removing only rollingUpdate gets re-defaulted. The documented kubectl patch --type=json that replaces /spec/strategy with {"type": "Recreate"} works, and the server-side apply then succeeds. CI covers only the Helm 3 path.
  • CI: all checks passed (CI passed, Chart, Chart install with the new "Upgrade strategy" step, Docs, Lint, Test, CodeQL, Read the Docs).

Declined review findings

  • Rename the heading "API update strategy Recreate": kept, as other sections use the same " " style, and the anchor is linked from the configuration reference and the deployment guide.
  • Express the Recreate/rollingUpdate rule in the schema (if/then): the schema can't see the merged default, so the template check stays the single place.
  • A CI step for server-side apply: verified by hand on kind (above); the chart's CI pins Helm 3, which uses client-side apply.

Open questions

None.

Closes #305

🤖 Generated with Claude Code

Summary by Sourcery

Set the API Deployment to use a safe Recreate strategy by default while providing validated alternatives for operators who require rolling upgrades.

New Features:

  • Add configurable API Deployment update strategies, defaulting to Recreate while supporting RollingUpdate and Kubernetes defaults.

Bug Fixes:

  • Prevent invalid rollingUpdate settings from being used with the Recreate strategy, which Kubernetes rejects.
  • Protect upgrades from serving tasks with an older API alongside a newer taskmaster.

Enhancements:

  • Document rollout downtime, safe two-step upgrades, and migration guidance for server-side-applied deployments.

CI:

  • Extend chart installation checks to verify migration from Kubernetes' default strategy to Recreate.

Documentation:

  • Document the new API update strategy configuration and its upgrade implications.

Tests:

  • Add coverage for strategy defaults, overrides, null handling, invalid combinations, and schema validation.

uniqueg and others added 6 commits November 15, 2026 13:31
Add the value tesk.strategy, rendered into the API Deployment's
spec.strategy, with the default type Recreate: one upgrade that brings
tesk-api 2.0.0 and taskmaster 0.12.0 must not leave an old API pod
serving tasks of the new taskmaster. Null leaves Kubernetes' default
(RollingUpdate), as before. The schema closes the map and checks the
type; the template fails on rollingUpdate with Recreate.

Refs #305

Co-Authored-By: Claude Opus 5.5 <[email protected]>
After the installation, upgrade the release to Kubernetes' default
strategy (as charts up to 0.3.0 had) and back to the chart's default,
and check that the Deployment ends up with type Recreate only.

Refs #305

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Add tesk.strategy to the configuration reference, and explain in the
upgrade notes why the default is Recreate, and how operators who
upgrade in two steps can keep RollingUpdate.

Refs #305

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Kubernetes rejects any rollingUpdate with Recreate, also an empty one.
Test explicit Recreate, empty maps and null rollingUpdate; correct the
schema description (an empty map keeps the default). The kind step
also checks that Kubernetes set a rollingUpdate before the upgrade, and
reports both checks the same way.

Refs #305

Co-Authored-By: Claude Opus 5.5 <[email protected]>
With server-side apply (Helm 4, Flux, Argo CD), Kubernetes keeps the
defaulted rollingUpdate and the upgrade to Recreate fails (checked on
kind): document a one-time kubectl patch. Mention the downtime in the
deployment guide and the chart README.

Refs #305

Co-Authored-By: Claude Opus 5.5 <[email protected]>
The startup probe doesn't bound the downtime; the patch is needed only
for releases of charts up to 0.3.0 upgraded with server-side apply.

Refs #305

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@uniqueg uniqueg self-assigned this Nov 15, 2026
@sourcery-ai

sourcery-ai Bot commented Nov 15, 2026

Copy link
Copy Markdown
Contributor

Reviewer's Guide

API

Define and validate the public tesk.strategy values contract, including allowed strategy fields and values.

  • charts/tesk/values.schema.json L3, L306-345

Implementation

Render the API Deployment strategy and reject rollingUpdate when the selected type is Recreate, which Kubernetes does not allow.

  • charts/tesk/templates/common/tesk-deployment.yaml L25-39

Configuration

Set Recreate as the default API Deployment strategy and document the available value in the chart defaults.

  • charts/tesk/values.yaml L97-108

Documentation

Explain the strategy’s upgrade-safety rationale, downtime implications, RollingUpdate alternative, and server-side apply migration step.

  • charts/tesk/README.md L17-18
  • docs/configuration.md L59
  • docs/deployment.md L72-78
  • docs/upgrading.md L15-70

Tests

Exercise the strategy defaults, overrides, null and invalid combinations, plus the chart-install upgrade from Kubernetes’ default strategy back to Recreate.

  • .github/actions/install-chart/action.yml L1-6, L40-68
  • tests/test_chart.py L754-872, L3413-3416, L3469-3470

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 15, 2026

Copy link
Copy Markdown

Codecov Report

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

Additional details and impacted files
@@            Coverage Diff            @@
##               dev      #306   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files            2         2           
  Lines          422       422           
=========================================
  Hits           422       422           

☔ 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 15, 2026 12:48
@sourcery-ai

sourcery-ai Bot commented Nov 15, 2026

Copy link
Copy Markdown
Contributor

Linked issues

Checked at commit c0311ac

#305 feat: set the API's update strategy (Recreate) · 4 of 4 met

# Requirement Status Notes
1 Add tesk.strategy for the API Deployment, defaulting to type: Recreate; null leaves Kubernetes' default. ✅ Met The value is defined in values.yaml and rendered into the Deployment; tests cover the Recreate default, custom strategies, and null.
2 Validate the strategy in the schema and templates, including rejecting rollingUpdate with Recreate. ✅ Met The schema constrains the allowed strategy fields and values, and the template fails when rollingUpdate is present with Recreate, including when it is empty.
3 Document the strategy in values.yaml, the configuration reference, and upgrade notes, including the reason for Recreate, its downtime, and the two-step RollingUpdate alternative. ✅ Met The values comments, configuration reference, and upgrade notes cover the default, the incompatible upgrade combination, downtime, and how to use RollingUpdate with a two-step upgrade.
4 Bump image versions and appVersion separately, after the tags are available. ✅ Met This change leaves image versions and appVersion unchanged, deferring those updates to the separate release-train change as described.

@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 1 issue

Prompt for AI Agents
Please address the comments from this code review:

## Individual Comments

### Comment 1
<location path=".github/actions/install-chart/action.yml" line_range="52" />
<code_context>
+      run: |
+        strategy() {
+          kubectl get deployment tesk-api -n "${NAMESPACE}" \
+              -o jsonpath='{.spec.strategy}'
+        }
+        helm upgrade tesk charts/tesk --namespace "${NAMESPACE}" \
</code_context>
<issue_to_address>
**Strategy check rejects valid deployments**

When the strategy is retrieved with kubectl’s default JSONPath printer, `strategy()` captures the strategy as Go-style map text, so `jq` cannot parse `before` and the upgrade strategy check exits with an error, even when the Deployment has the expected strategy.

Have `strategy()` emit valid JSON for the selected strategy before passing it to `jq`.
</issue_to_address>

Sourcery assessment

Needs a human reviewer. 1 finding to address first, and with Recreate, each API rollout stops the old pod before the replacement is ready, so clients can experience an API outage; reverting restores the prior rollout behavior, but cannot undo outages that already occurred.

Blocking findings: .github/actions/install-chart/action.yml:52


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

@uniqueg
uniqueg merged commit 29e5c79 into dev Nov 15, 2026
39 checks passed
@uniqueg
uniqueg deleted the feat/305-api-strategy branch November 15, 2026 12:52
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: set the API's update strategy (Recreate)

1 participant