Skip to content

feat(chart): support restricted namespaces - #331

Merged
uniqueg merged 5 commits into
devfrom
feat/330-restricted-namespaces
Nov 22, 2026
Merged

uniqueg merged 5 commits into
devfrom
feat/330-restricted-namespaces

Conversation

@uniqueg

@uniqueg uniqueg commented Nov 21, 2026 •

Copy link
Copy Markdown
Member

Closes #330

Summary

Values for namespaces that enforce the restricted Pod Security Standard and have a quota on limits.cpu (CERIT-SC, generic-issues#122):

  • tesk.taskmaster.podSecurityContext, securityContext, resources; tesk.filer.resources; tesk.executor.podSecurityContext, securityContext (now the container's context), defaultCpu. They map to the env vars of tesk-api 2.1.0 (tesk-api#210) and to FILER_RESOURCES (taskmaster 0.12.0+). Quantities go on as strings.
  • Executor compatibility: runAsUser/runAsGroup/fsGroup/runAsNonRoot still go into the <prefix>-executor ConfigMap, so tesk-api 2.0.0 still applies them. fsGroup in tesk.executor.securityContext fails with a hint to move it to podSecurityContext (breaking, see upgrading.md).
  • Schema checks; the notes warn when tesk-api is older than 2.1.0, and for tesk.filer.resources with a taskmaster older than 0.12.0.
  • CI: chart-install is a matrix, Chart install (default) and Chart install (restricted). The restricted case labels the namespace with PSA enforce=restricted, applies tests/smoke/restricted/quota.yaml (a limits.cpu quota and a 512Mi default memory limit) and installs with tests/smoke/restricted/values.yaml. The required check is still only CI passed, so the ruleset doesn't change. release.yml still installs the default case only.
  • Docs: the configuration table, deployment "Restricted namespaces and quotas" (with the same values as the smoke file, checked by a test), the "Resources" section (the old "v0.10.6 sets requests as limits" claim is corrected), "Executors as non-root users", upgrading "Unreleased: Security contexts and resources of task pods", and development (the matrix).

Decisions taken

  • The securityContext/podSecurityContext split for executors, with fsGroup moving to podSecurityContext (main session, 2026-11-22). The CERIT runbook gi-122 was updated to match. uniqueg may veto.

Release dependency

  • tests/smoke/restricted/values.yaml pins the tesk-api dev image sha-b87b051… (the merge of tesk-api#210) until tesk-api 2.1.0 is released. test_restricted_values_pin fails once appVersion is 2.1.0 or later and the pin is still there, so the chart's release prep has to remove it.

Verification

  • REQUIRE_HELM=1 pytest tests/test_chart.py (Helm 3.22.1): 981 passed. The full pytest run passed too (1178 at the time).
  • pre-commit run --all-files: all hooks pass (ruff, mypy, actionlint, check-yaml, …).
  • mkdocs build --strict: OK.
  • A local replica of the restricted install-chart case on kind 0.33 (PSA restricted plus quota): the API ran, and tests/smoke/deployment.sh passed: a task COMPLETE, a task with an input COMPLETE (filer with its hardened defaults), and a cancelled task CANCELED. The events showed no admission refusals.
  • CI on 8a89881: CI passed, including Chart install (default) and Chart install (restricted).
  • Reviews: two rounds of adversarial and quality review. Fixed: zero defaultCpu (tesk-api refuses it), null fsGroup in the container context (now left out of the env JSON), old-API notes only for settings that ask for something, a docs/smoke sync test, a pin-removal test, version phrasing.

Declined review findings

  • Round 2, low: tell the schema refusal from the template refusal in test_executor_default_cpu_zero. Declined because either refusal is correct.

  • Quality review, low: share one list of legacy executor fields between tesk.executorSecurityContext and the notes. Declined because Helm templates make sharing awkward, and the tests pin the behaviour.

  • Quality review, low: enforce "no fsGroup in the container context" in the schema too. Declined because the template's failure carries the migration hint, which a schema error wouldn't.

🤖 Generated with Claude Code

Summary by Sourcery

Support deploying the chart in namespaces enforcing the restricted Pod Security Standard or CPU quotas by configuring task pod security contexts and resources.

New Features:

  • Add configuration for task pod security contexts and resource requirements, including executor default CPU, to support restricted namespaces and CPU quotas.

Bug Fixes:

  • Preserve executor security-context compatibility across tesk-api versions while rejecting invalid or incompatible settings with actionable errors.

Enhancements:

  • Add version-aware warnings for settings unsupported by older tesk-api and taskmaster releases.
  • Serialize resource quantities safely for tesk-api and taskmaster consumption.

CI:

  • Run chart installation smoke tests in both default and restricted namespace configurations.

Documentation:

  • Document restricted namespace and quota configuration, task pod resources, executor security contexts, and the breaking executor context migration.

Tests:

  • Expand chart tests for security contexts, resources, CPU defaults, compatibility warnings, restricted values, and documentation synchronization.

Work in progress for #330: values for the security contexts and
resources of taskmaster, filer and executor pods (tesk-api 2.1.0,
taskmaster 0.12.0), the executors' default CPU, schema, notes
warnings, and a restricted case of the install-chart action.
Tests, docs and the ci.yml matrix are still missing.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@sourcery-ai

sourcery-ai Bot commented Nov 21, 2026 •

Copy link
Copy Markdown
Contributor

Reviewer's Guide

API

Review the chart values schema as the public contract for the new task pod security contexts, resources, and executor CPU setting.

  • charts/tesk/values.schema.json L58-80, L152-169, L209-289 (+3 small edits)

Implementation

Check how the chart serializes task resources and security contexts into tesk-api environment variables and preserves executor ConfigMap compatibility.

  • charts/tesk/templates/_helpers.tpl L187-219, L227, L235-272
  • charts/tesk/templates/common/tesk-deployment.yaml L140-183

Check the chart's warnings for settings ignored by older tesk-api or taskmaster versions.

  • charts/tesk/templates/_helpers.tpl L529-583, L614

Configuration

Review the new defaults and value descriptions, especially the executor pod/container context split and the default CPU behavior.

  • charts/tesk/values.yaml L51-65, L88-123

Check that the install action prepares restricted namespaces and applies the restricted values consistently during install and upgrades.

  • .github/actions/install-chart/action.yml L10-17, L45-74, L84-90 (+3 small edits)

Check that CI exercises both default and restricted chart installs while keeping the release workflow's default case unchanged.

  • .github/workflows/ci.yml L149-159, L167-168

Documentation

Review the configuration reference and deployment guidance for the new values, restricted namespaces, resource behavior, and executor context migration.

  • docs/configuration.md L56-59 (+4 small edits)
  • docs/deployment.md L706-804, L900-906 (+2 small edits)

Check the upgrade guidance for the breaking executor context change and the new task pod settings.

  • docs/upgrading.md L13-63, L635-638

Review the development documentation describing the default and restricted CI install cases.

  • docs/development.md L58-66

Tests

Review the restricted namespace quota and values fixtures used by CI and chart rendering tests.

  • tests/smoke/restricted/quota.yaml L1-27
  • tests/smoke/restricted/values.yaml L1-45

Check coverage for executor context compatibility, task pod settings and resources, validation, warnings, and synchronization of restricted values with the documentation.

  • tests/test_chart.py L1052-1110, L1144-1450, L5061-5214 (+12 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 21, 2026 •

Copy link
Copy Markdown

Codecov Report

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

Additional details and impacted files
@@            Coverage Diff            @@
##               dev      #331   +/-   ##
=========================================
  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 and others added 3 commits November 22, 2026 06:29
Tests for the task pods' security contexts and resources, the
executors' pod and container contexts (fsGroup moved), the default CPU,
the notes for tesk-api before 2.1.0 and the restricted smoke values; a
chart-install matrix (default, restricted) in CI; docs for the new
values, restricted namespaces and quotas, and the upgrade.

Refs #330

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Check that the deployment guide's restricted values are the smoke
test's and that the tesk-api pin goes with appVersion 2.1.0; name the
chart version after 0.4.0 in the fsGroup hint; name tesk-core#164 for
the filer defaults; note that releases install the default case only.

Refs #330

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Fail on a zero tesk.executor.defaultCpu, which tesk-api 2.1.0 refuses
at startup; let a null fsGroup in tesk.executor.securityContext pass
(e.g., to drop the old one with --reuse-values); warn of older tesk-api
only for settings that ask for something.

Refs #330

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@uniqueg
uniqueg marked this pull request as ready for review November 22, 2026 11:23
@sourcery-ai

sourcery-ai Bot commented Nov 22, 2026 •

Copy link
Copy Markdown
Contributor

Linked issues

Checked at commit b538de2

#330 feat(chart): support restricted namespaces and quotas · 5 of 6 met

# Requirement Status Notes
1 Expose taskmaster, filer and executor security-context/resource settings, including executor default CPU, with component defaults preserved. ✅ Met The chart adds the requested values; null leaves component defaults in place, and empty maps can explicitly set none.
2 Provide schema checks for the new values. ✅ Met The schema validates the new context, resource, and CPU values, with template checks for invalid quantities and zero default CPU.
3 Document an opt-in restricted-namespace preset and the configuration, deployment, and upgrade behavior. ✅ Met The deployment guide documents the preset and its caveats, and the configuration and upgrading guides describe the new values and migration.
4 Run a smoke test in CI in a restricted, quota'd namespace, with a task using an input and output reaching COMPLETE. ✅ Met The CI matrix runs the restricted install with Pod Security enforcement and a CPU quota; its deployment script checks a task with an input reaches COMPLETE and verifies the input content in task logs.
5 Bump tesk-api and tesk-core to releases that contain the settings. 🟡 Partly met The restricted smoke values pin a tesk-api development image, while the chart's default API version remains 2.0.0; the required released component versions have not been adopted.
6 Keep default rendering the same as before, apart from the new default limits documented in the upgrade notes. ✅ Met The new settings default to null or empty values and are omitted unless configured; the upgrade notes describe the component defaults that apply with newer versions.

@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 6 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="262" />
<code_context>
+{{- else if kindIs "invalid" $quantity -}}
+{{- fail (printf "%s.%s.%s has no value: give a quantity, or leave it out" $key $field $name) -}}
+{{- else -}}
+{{- $_ := set $strings $name (toString $quantity) -}}
+{{- end -}}
+{{- end -}}
</code_context>
<issue_to_address>
**Boolean quantities break task pods**

When a resource request or limit is set to a boolean, `tesk.resourcesJson` converts it to `true`, so tesk-api or the taskmaster rejects the Kubernetes quantity and the affected task pods fail to start.

Reject boolean resource quantities during chart rendering instead of stringifying them.
</issue_to_address>

### Comment 2
<location path="charts/tesk/templates/_helpers.tpl" line_range="256" />
<code_context>
+{{- range $name, $quantity := $quantities -}}
+{{- if and (kindIs "float64" $quantity) (eq (floor $quantity) $quantity) -}}
+{{- if not (and (lt $quantity 9007199254740992.0) (gt $quantity -9007199254740992.0)) -}}
+{{- fail (printf "%s.%s.%s is a number too large to be exact: quote it in the values file or use --set-string" $key $field $name) -}}
+{{- end -}}
+{{- $_ := set $strings $name (printf "%.0f" $quantity) -}}
</code_context>
<issue_to_address>
**Exact quantity blocks rendering**

When an unquoted resource quantity is exactly 9007199254740992, `tesk.resourcesJson` treats the exactly representable 2^53 value as out of range because both bounds are strict, so Helm rendering fails.

Allow the exact boundary value while continuing to reject whole numbers outside the exact range.
</issue_to_address>

### Comment 3
<location path="tests/smoke/restricted/values.yaml" line_range="12" />
<code_context>
+    # resources of task pods), until tesk-api 2.1.0 is released: the chart's
+    # release prep that sets `appVersion` 2.1.0 removes it (a chart test
+    # fails while both are set)
+    tag: sha-b87b051ba1389b3696828579df1e78788488bb3f
+  taskmaster:
+    podSecurityContext:
</code_context>
<issue_to_address>
**Default API remains 2.0.0**

The restricted smoke values pin a development build with the new settings, but the chart's default API version remains 2.0.0. Consequently, the default installation does not use a tesk-api release containing these settings.
</issue_to_address>

### Comment 4
<location path=".github/actions/install-chart/action.yml" line_range="10" />
<code_context>
-# hardened defaults (`tests/smoke/check-filer.sh`). Used by the
-# `chart-install` job of `ci.yml` and by `release.yml`. Needs a checkout of
-# the repository.
+# hardened defaults (`tests/smoke/check-filer.sh`). With `restricted:
+# true`, the namespace enforces the `restricted` Pod Security Standard and
+# has a quota on `limits.cpu` and a default memory limit
</code_context>
<issue_to_address>
**Smoke test lacks task output**

The restricted case runs the existing smoke checks, whose input task completes and verifies its output in logs. It does not declare or check a TES task output, as the issue asks.
</issue_to_address>

### Comment 5
<location path="tests/test_chart.py" line_range="5127" />
<code_context>
[email protected](
+    ("tag", "old"),
+    [
+        (None, True),
+        ("v2.0.1", True),
+        ("2.1.0", False),
</code_context>
<issue_to_address>
**Default-version warning test breaks on release**

When the chart's `appVersion` is 2.1.0 or later and the test leaves the API tag unset, `test_notes_task_pod_settings_old_api` treats the unset tag as old and expects a warning. Once `appVersion` reaches 2.1.0, the unset API tag defaults to `appVersion`, so the correct notes omit the warning and this test fails.

Derive the expected `old` value from the default API tag, or set an explicit old tag for this test case.
</issue_to_address>

### Comment 6
<location path="charts/tesk/templates/_helpers.tpl" line_range="535" />
<code_context>
+{{- $ignored := list -}}
+{{- $taskmaster := default dict .Values.tesk.taskmaster -}}
+{{- range $key := list "podSecurityContext" "securityContext" -}}
+{{- if and (kindIs "map" (get $taskmaster $key)) (get $taskmaster $key) -}}
+{{- $ignored = append $ignored (printf "tesk.taskmaster.%s" $key) -}}
+{{- end -}}
</code_context>
<issue_to_address>
**Null contexts trigger false warnings**

When an older tesk-api is used with taskmaster or executor contexts containing only null-valued fields, the notes logic adds these maps or keys to `$ignored` without checking their values, so Helm reports settings as ignored even though they request no pod configuration.

Exclude null-valued fields when deciding whether context settings are ignored.

Also at `charts/tesk/templates/_helpers.tpl:548-549`.
</issue_to_address>

Sourcery assessment

Needs a human reviewer. 6 findings to address first, and the chart now forwards security contexts and resource settings that determine how taskmaster, filer, and executor pods run; a mapping or precedence error could leave pods rejected or running with unintended security or resource constraints. Reverting restores the chart behavior, but task pods already created with the wrong settings may continue until they are stopped or finish.

Blocking findings: charts/tesk/templates/_helpers.tpl:262, charts/tesk/templates/_helpers.tpl:256, tests/smoke/restricted/values.yaml:12, .github/actions/install-chart/action.yml:10, tests/test_chart.py:5127, and 1 more


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
Comment thread tests/smoke/restricted/values.yaml Resolved
Comment thread tests/test_chart.py Resolved
Comment thread charts/tesk/templates/_helpers.tpl Resolved
Fail on boolean resource quantities instead of passing "true" on; let
the notes ignore null fields of task pod contexts; derive the expected
warning of the chart's default tesk-api tag from appVersion.

Refs #330

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@uniqueg
uniqueg merged commit eef0c54 into dev Nov 22, 2026
25 checks passed
@uniqueg
uniqueg deleted the feat/330-restricted-namespaces branch November 22, 2026 11:39
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): support restricted namespaces and quotas

1 participant