Repository navigation
feat: set the tesk-api CORS origins in the chart - #310
Conversation
The chart's appVersion (the default tag of the API's image) is 2.0.0, and the taskmaster and filer images default to 0.12.0. One helm upgrade brings both in the order they need, as the API's Deployment uses the Recreate strategy (#305). The notes warn about auth.tokenClients for tesk-api before 2.0.0, the first release with the setting (was: before 1.2.1-0). The chart's service info reports TES 1.1.0 for tesk-api 2.0.0 and later (and for tags that aren't versions), and TES 1.0.0 before, as tesk-api 2.0.0 implements TES 1.1. Refs #308 Co-Authored-By: Claude Opus 5.5 <[email protected]>
Pull the docs of tesk-api v2.0.0 and tesk-core v0.12.0 into the site, so that the links of the tesk-api 2.0.0 release notes (upgrading/#to-200, "Tokens of services") resolve. Add upgrade notes for the new default images: pinned tags and the upgrade order, the hardened filer pods on clusters that refuse the RuntimeDefault seccomp profile, the service info's TES version, and the API changes for clients. The configuration reference and the deployment guide name the new defaults. Refs #308 Co-Authored-By: Claude Opus 5.5 <[email protected]>
tesk.apiBefore replaces four copies of the version check of the API's tag (notes and service info). Docs: /v3/api-docs of tesk-api 2.0.0, the tokenClients requirement in the configuration reference, one place for the filer's seccomp advice; test_default_images checks the rendered image. Refs #308 Co-Authored-By: Claude Opus 5.5 <[email protected]>
- tesk.filer.podSecurityContext and tesk.filer.securityContext replace the taskmaster's defaults for the filer pods (FILER_POD_SECURITY_CONTEXT and FILER_SECURITY_CONTEXT), e.g. on clusters that refuse pods asking for the RuntimeDefault seccomp profile; null keeps the defaults. - The FTP secret's name also goes to the taskmasters as TESK_FTP_SECRET_NAME, so that filer jobs of taskmaster 0.12.0 reference it instead of holding the credentials. - The notes warn about taskmaster 0.12.0 or later with tesk-api before 2.0.0, which reports wrong task states. Docs: upgrade notes, configuration reference, deployment guide. Refs #308 Co-Authored-By: Claude Opus 5.5 <[email protected]>
Add pre-release cases to the notes test for taskmaster 0.12.0 with an older tesk-api, parametrize the filer security context test on JSON values, and read tesk.apiBefore the same way everywhere. Docs: rewrap lines, note that Helm merges the filer's security contexts across values files, and the ignore_error exception with taskmaster 0.11.0. Refs #308 Co-Authored-By: Claude Opus 5.5 <[email protected]>
The value tesk.cors.allowedOrigins (a list, default empty) becomes TESK_API_CORS_ALLOWED_ORIGINS of tesk-api 2.0.0, joined by commas, only when it isn't empty. The schema refuses wildcards, paths, user info, commas and origins without a scheme, which tesk-api would refuse at startup; the notes warn if origins are set with tesk-api before 2.0.0, which ignores them. Docs: deployment guide (Browser clients (CORS)), configuration reference, upgrade notes. Closes #307 Co-Authored-By: Claude Opus 5.5 <[email protected]>
Tags that look like versions but aren't SemVer (e.g. 1.2.3- or 0.12.0-foo..bar) made semverCompare fail the render. The API and taskmaster checks now accept only SemVer pre-release and build parts, and treat other tags as tags that aren't versions. Docs: the taskmaster checks the filer's security contexts and falls back to its defaults. Refs #308 Co-Authored-By: Claude Opus 5.5 <[email protected]>
The schema now accepts only http(s) origins with an ASCII host name, an IPv4 address as four decimal numbers or a bracketed IPv6 address, and a port from 1 to 65535 without leading zeros and other than the default: tesk-api 2.0.0 stops at startup on other origins, which left the API down after an upgrade with the Recreate strategy. Docs: the CORS section as a list; a test of its own for notes without origins. Refs #307 Co-Authored-By: Claude Opus 5.5 <[email protected]>
…i/TESK into feat/307-cors-origins
The schema now checks IPv6 literals as such (malformed ones such as [1] or [::1::2] stopped tesk-api at startup), and accepts what tesk-api accepts: schemes in any case, host names with a trailing dot. It stays stricter for IPv6 zone IDs and single-label hosts that start with a digit, as the docs say. Refs #307 Co-Authored-By: Claude Opus 5.5 <[email protected]>
Reviewer's GuideConfigurationDefine and validate
Pass nonempty origins to tesk-api as
DocumentationExplain how to configure browser-client CORS, the origin validation rules, token implications, and the minimum supported API version.
TestsTest origin rendering and schema rejection, unknown CORS keys, and version-dependent install notes.
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 #310 +/- ##
=========================================
Coverage 100.00% 100.00%
=========================================
Files 2 2
Lines 422 422
=========================================
Hits 422 422 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
Linked issuesChecked at commit 35a2a15 #307 feat: set the tesk-api CORS origins in the chart · 3 of 3 met
|
There was a problem hiding this comment.
Hey - I've found 3 issues
Prompt for AI Agents
Please address the comments from this code review:
## Individual Comments
### Comment 1
<location path="charts/tesk/values.yaml" line_range="50" />
<code_context>
image:
repository: docker.io/elixircloud/tesk-core-taskmaster
- tag: 0.11.0
+ tag: 0.12.0
# Image of the filer (tesk-core), which stages the inputs and outputs; its
# tag must be the same release as the taskmaster's (the installation
</code_context>
<issue_to_address>
**Tasks get incorrect statuses**
When an existing release pins `tesk.image.tag` below 2.0.0 but leaves its taskmaster and filer image tags unset when upgrading, the chart deploys taskmaster 0.12.0 with the pinned older API, which treats filer jobs as executor jobs and reports incorrect task states that are persisted for tasks.
Fail chart rendering for this incompatible API/taskmaster combination, or otherwise keep the new taskmaster default from being deployed with an older pinned API.
Also at `charts/tesk/templates/_helpers.tpl:394-401`.
</issue_to_address>
### Comment 2
<location path="charts/tesk/templates/_helpers.tpl" line_range="104" />
<code_context>
+`version` (X.Y.Z) */ -}}
+{{- define "tesk.apiBefore" -}}
+{{- $apiTag := include "tesk.apiImageTag" .root | trimPrefix "v" -}}
+{{- if and (regexMatch "^[0-9]+\\.[0-9]+(\\.[0-9]+)?(-[0-9A-Za-z-]+(\\.[0-9A-Za-z-]+)*)?(\\+[0-9A-Za-z-]+(\\.[0-9A-Za-z-]+)*)?$" $apiTag) (semverCompare (printf "<%s-0" .version) $apiTag) -}}
+true
+{{- end -}}
</code_context>
<issue_to_address>
**Helm rendering rejects image tags**
When an API or taskmaster image tag has a leading-zero version component or numeric prerelease identifier, the tag regexes admit these strings, then `semverCompare` rejects `$apiTag` or `$taskmasterTag`; Helm aborts rendering, so installs, upgrades, and template rendering fail.
Make both tag regexes admit only SemVer strings `semverCompare` can parse, and treat invalid tags as unchecked.
Also at `charts/tesk/templates/_helpers.tpl:394`.
</issue_to_address>
### Comment 3
<location path="charts/tesk/templates/common/tesk-deployment.yaml" line_range="232" />
<code_context>
+ origins) */}}
+ {{- with dig "cors" "allowedOrigins" list $tesk }}
+ - name: TESK_API_CORS_ALLOWED_ORIGINS
+ value: {{ join "," . | quote }}
+ {{- end }}
{{- if .Values.transfer.enabled }}
</code_context>
<issue_to_address>
**Browser requests fail CORS**
When an allowed origin has uppercase scheme or host characters, a trailing slash, an expanded IPv6 literal, or another spelling the browser serializes differently, the chart joins the configured origins unchanged, and tesk-api compares them exactly with the browser’s serialized `Origin`; the values do not match, so the browser blocks the API response.
Canonicalize each configured origin to the browser’s serialized form before passing the joined values to tesk-api.
Also at `tests/test_chart.py:1285`, `tests/test_chart.py:1287`, `tests/test_chart.py:1302-1305`, `charts/tesk/templates/common/tesk-deployment.yaml:233`.
</issue_to_address>Sourcery assessment
Needs a human reviewer. 3 findings to address first, and the chart now deploys a new API/taskmaster pair, and task runs may create states and outputs that a rollback cannot undo if their behavior is wrong. When configured, the CORS origins also let browsers at those origins read API responses using a user's token; reverting removes the headers, but cannot undo data already exposed.
Blocking findings: charts/tesk/values.yaml:50, charts/tesk/templates/_helpers.tpl:104, charts/tesk/templates/common/tesk-deployment.yaml:232
Taskmaster 0.12.0 and later with tesk-api before 2.0.0 report wrong task states, e.g. after an upgrade with values that pin an older tesk.image.tag but not the taskmaster. The installation now fails for such a pair instead of the notes warning about it. The version checks accept only SemVer that semverCompare reads as written (no leading zeros in numbers and numeric pre-release parts), so tags such as 01.2.3 or 1.2.3-01 count as tags that aren't versions. Refs #308 Co-Authored-By: Claude Opus 5.5 <[email protected]>
The CORS notes tests now pin taskmaster and filer 0.11.0 for older tesk-api tags, which the chart refuses with taskmaster 0.12.0. Co-Authored-By: Claude Opus 5.5 <[email protected]>
tesk-api compares origins as text, so a long-form IPv6 origin passes its startup check but never matches the short form that browsers send. Refs #307 Co-Authored-By: Claude Opus 5.5 <[email protected]>
Closes #307
Stacked on #309 (branched from
build/308-tesk-api-2.0.0, which is merged in): until #309 is merged, this diff also shows its commits. Review the commitsfeat: set the tesk-api CORS origins in the chart,fix: refuse origins that tesk-api refuses,fix: match tesk-api's CORS origin rulesanddocs: list IPv6 CORS origins in the short form(the merge of #309 at 6225b88 only adapts the CORS notes tests to its taskmaster check); after #309 is merged,devneeds to be merged into this branch.Summary
tesk-api 2.0.0 answers cross-origin requests of the origins in
TESK_API_CORS_ALLOWED_ORIGINS(elixir-cloud-aai/tesk-api#195). The chart gets a value for it:tesk.cors.allowedOrigins(list, default[]) invalues.yaml, documented likeauth.serviceInfoPublic, and invalues.schema.json.templates/common/tesk-deployment.yamlsetsTESK_API_CORS_ALLOWED_ORIGINSto the list joined with,, only when the list isn't empty (alsotesk.cors: nullandallowedOrigins: nullleave it out).Recreatestrategy): onlyhttp/https(any case), an ASCII host name without_(optionally with a trailing dot), an IPv4 address as four decimal numbers or a well-formed bracketed IPv6 address, and a port from 1 to 65535 without leading zeros and other than the default; no wildcards, paths, user info or commas. Checked against a copy of tesk-api'sCorsConfigvalidation on 46 origins: the same verdict for all but IPv6 zone IDs and single-label hosts starting with a digit, which the chart refuses on purpose (documented).helm install/helm upgradewarn if origins are set with tesk-api before 2.0.0, which ignores them.How it was verified
helm lint charts/tesk --strict(Helm 3.22.1): passed.REQUIRE_HELM=1 pytest tests/test_chart.py: 737 passed (with build: use tesk-api 2.0.0 in the chart #309 merged in) (new:test_cors_allowed_origins,test_cors_allowed_origins_invalidwith 30 invalid origins,test_cors_unknown_key,test_notes_cors_old_api,test_notes_cors_unset_old_api; written first and failing before the change).coverage run -m pytest --ignore=tests/test_chart.py: 175 passed, 100% coverage.pre-commit run --all-files: passed.mkdocs build --strict: passed; anchorsdeployment/#browser-clients-corsandtesk-api/configuration/#cross-origin-requests-corsexist.allowedOrigins: [https://client.example.org, http://localhost:3000], cluster deleted afterwards: preflightOPTIONS /tasksfromhttps://client.example.org→ 200 withAccess-Control-Allow-Origin: https://client.example.org;GET /tasksfromhttp://localhost:3000→ 200 with that origin; fromhttps://evil.example.org→ 403 without CORS headers; withoutOrigin→ 200./; expanded IPv6 never matches what browsers send, now documented instead of canonicalized in a template.Declined review findings
Two review rounds (adversarial and quality); fixed: origins that the first schema let through but tesk-api refuses at startup (default ports, leading zeros,
_, malformed IPv4/IPv6, other schemes), the CORS section as a list, a separate test for notes without origins. Declined:tesk-api/configuration.md#cross-origin-requests-corspoints to docs that are pulled in at build time; the strict build with the pinned tesk-api v2.0.0 docs resolves it, so it stays.3com), which tesk-api accepts: matching tesk-api there would need a much more complex pattern for no practical gain.Open questions
None.
🤖 Generated with Claude Code
Summary by Sourcery
Configure and validate browser CORS origins in the tesk Helm chart for tesk-api 2.0.0 and later.
New Features:
Bug Fixes:
Enhancements:
Documentation:
Tests: