Repository navigation
build(chart)!: use the FOCA library chart - #252
Conversation
The release pin check also fails for chart dependencies whose repository is not an OCI or HTTPS repository, e.g., a `file://` path to a checkout of a FOCA commit, which the chart uses until foca-common 0.2.0 is released (#246). Co-Authored-By: Claude Opus 5.5 <[email protected]>
Replace the chart with a thin chart over FOCA's library chart foca-common 0.2.0: one-line templates for the app, the Celery worker, MongoDB and the RabbitMQ broker (Deployment, Service, Ingress, Gateway API HTTPRoute or OpenShift Route, NetworkPolicies, persistence), the app's settings and checks in `_helpers.tpl`, camelCase values with a schema, and no default credentials: MongoDB, the broker and Flower use Secrets of the deployment, and `protes.extraEnv` passes further variables (e.g., credentials for TES instances, #213) to the app and the worker. Flower is optional and off by default, with basic authentication and a NetworkPolicy that admits no one by default. Rendering fails for values of the legacy chart, and upgrades of legacy releases fail, as they would delete the MongoDB volume. foca-common 0.2.0 is not released yet, so the chart takes it from a FOCA commit, checked out by `scripts/foca_common.sh` (temporary, #246). CI builds the chart's dependencies for the tests, and a new job lints and tests the chart. BREAKING CHANGE: the chart's values, resource names and selectors change, and it creates no Secrets; releases of the legacy chart must be reinstalled (see deployment/README.md, From the legacy chart). Co-Authored-By: Claude Opus 5.5 <[email protected]>
Rewrite the chart's README (the deployment page) for the chart on the library chart: configuration, image, installation, Secrets, names, exposing the app, the Celery worker and broker, Flower, security contexts, network policies, MongoDB, and the move from the legacy chart. Add the development of the chart, and upgrade notes; the Ingress now routes all paths, including the permissions API. Co-Authored-By: Claude Opus 5.5 <[email protected]>
- Check issuers only if access control is enabled, and groups and admins only if it is also enforced, as the app does. - Detect releases of the legacy chart by their Deployments, not by claims, which may outlast an uninstallation (protes.failIfLegacy). - Tolerate a null protes value in the extraEnv helpers. - Flag chart dependencies without a repository in the release check. - Test the reserved variables, legacy upgrades, the order of checks, Flower's ports and Flower with an external broker. - Rename ci/flower-values.yaml to ci/optional-values.yaml; rewrap docs. Co-Authored-By: Claude Opus 5.5 <[email protected]>
With access control disabled, the app starts without issuers only if `enforce` and `policies` are unset too, and then rejects every token, so the chart keeps requiring issuers; groups and admins are still required only if access control is enabled and enforced. Also rewrap a README paragraph and a long test literal. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Resolve conflicts with the releases from tags (#230): the chart on foca-common replaces the legacy templates and the image helper, keeps appVersion dev and documents released charts and image tags; the release workflow builds the library chart before linting (strictly, with the CI values) and packaging the chart, and checks the packaged library version. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Reviewer's GuideThe PR replaces the legacy Helm chart with a thin, schema-validated wrapper around FOCA’s Sequence diagram for chart dependency build and release packagingsequenceDiagram
participant CI as CI or release workflow
participant Script as foca_common.sh
participant FOCA as FOCA repository
participant Helm as Helm
participant Chart as proTES chart
CI->>Script: checkout pinned FOCA commit
Script->>FOCA: fetch foca-common chart
FOCA-->>Script: library chart at pinned commit
Script-->>CI: .foca-common checkout
CI->>Helm: helm dependency build deployment
Helm->>Chart: resolve file dependency
Chart-->>Helm: package foca-common
Helm->>Chart: helm lint or helm package
Chart-->>CI: validated chart artifact
Sequence diagram for rendering app and worker environment configurationsequenceDiagram
participant Helm
participant Validation as protes.validate
participant Library as foca-common templates
participant Deployments as App and worker Deployments
participant Secret as Kubernetes Secrets
Helm->>Validation: protes.settings
Validation->>Validation: checkSecurity
Validation->>Validation: checkExtraEnv
Validation-->>Helm: validated settings
Helm->>Library: foca-common.deployment
Helm->>Library: foca-common.workerDeployment
Library-->>Helm: rendered Deployment manifests
Helm->>Helm: protes.withExtraEnv
Helm-->>Deployments: add protes.extraEnv when configured
Deployments->>Secret: read broker and database credentials
File-Level Changes
Assessment against linked issues
Possibly linked issues
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 #252 +/- ##
=========================================
Coverage 100.00% 100.00%
=========================================
Files 25 25
Lines 1216 1226 +10
=========================================
+ Hits 1216 1226 +10 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
Hey - I've found 7 issues
Prompt for AI Agents
Please address the comments from this code review:
## Individual Comments
### Comment 1
<location path="deployment/values.yaml" line_range="91-92" />
<code_context>
+
+ ```yaml
+ protes:
+ ingress:
+ enabled: false
+ httpRoute:
+ enabled: true
+ parentRefs:
+ - name: gateway
</code_context>
<issue_to_address>
**Bearer tokens travel over HTTP**
When an operator installs the chart with its default Ingress settings and no separate TLS-terminating proxy in front of the cluster, the chart creates an Ingress by default without TLS, so clients that follow the installation notes and send bearer tokens to that endpoint transmit them in cleartext. An observer on the network can capture the tokens and use them to access the API.
Require TLS for the default Ingress, or disable the Ingress by default and require an explicit choice of a TLS-terminating exposure path.
Also at `deployment/values.yaml:105`.
</issue_to_address>
### Comment 2
<location path="deployment/templates/_helpers.tpl" line_range="285-286" />
<code_context>
+{{- define "protes.checkUpgrade" -}}
+{{- if .Release.IsUpgrade -}}
+{{- $deployments := lookup "apps/v1" "Deployment" .Release.Namespace "" | default dict -}}
+{{- range $deployment := (get $deployments "items" | default list) -}}
+{{- include "protes.failIfLegacy" (dict "root" $ "resource" $deployment) -}}
+{{- end -}}
+{{- end -}}
</code_context>
<issue_to_address>
**Legacy database data is unprotected**
When a legacy release still has its MongoDB PVC but no Deployments, and an operator upgrades it, `protes.checkUpgrade` checks only Deployments, skips `failIfLegacy`, and Helm removes the old PVC during the upgrade, making the legacy database data unavailable.
Check for the legacy MongoDB PVC as well as Deployments and block the upgrade when it remains.
</issue_to_address>
### Comment 3
<location path="deployment/README.md" line_range="594" />
<code_context>
+ ```bash
+ kubectl exec deploy/mongodb -n <namespace> -- sh -c 'mongodump --quiet \
+ -u "$MONGO_INITDB_ROOT_USERNAME" -p "$MONGO_INITDB_ROOT_PASSWORD" \
+ --authenticationDatabase admin --db taskStore --archive' \
+ > taskStore.archive \
+ && kubectl exec -i deploy/mongodb -n <namespace> -- sh -c 'mongorestore \
</code_context>
<issue_to_address>
**Custom database records are omitted**
When a legacy deployment stores tasks outside `taskStore` or stores access-control rules in a separate database, the migration exports only `taskStore`, so tasks in a legacy database named by `mongodb.secret.databaseName` are absent from the archive; if access-control rules use a separate configured database, those `policy_rules` are omitted too. Uninstalling the legacy release then removes the source volume, leaving that data unavailable.
Make the migration dump and restore every configured database, including the legacy task database and any separate access-control database.
</issue_to_address>
### Comment 4
<location path="deployment/templates/_helpers.tpl" line_range="193" />
<code_context>
+containers, which `protes.extraEnv` must not set again.
+*/}}
+{{- define "protes.reservedEnv" -}}
+{{- list "FOCA_CONFIG_OVERLAY" "GUNICORN_CMD_ARGS" "MONGO_USERNAME" "MONGO_PASSWORD" "CELERY_BROKER_URL" "CELERY_RESULT_BACKEND" | toJson -}}
+{{- end -}}
+
</code_context>
<issue_to_address>
**MongoDB denies alternate database access**
When `protes.extraEnv` sets `MONGO_DBNAME` to a database other than the provisioned databases while bundled MongoDB authentication is enabled, the chart provisions MongoDB access for `taskStore` and the configured access-control database, but the app and worker use the overridden database. MongoDB rejects their reads and writes, leaving task or permission data unavailable.
Prevent `MONGO_DBNAME` from being overridden, or provision MongoDB access for the overridden database.
Also at `deployment/templates/_helpers.tpl:19-20`.
</issue_to_address>
### Comment 5
<location path="deployment/values.yaml" line_range="7-8" />
<code_context>
+# (see `Chart.yaml`), which reads these values (see deployment/README.md).
-applicationDomain: ""
+# Resource names are derived from the release name: `<release>-protes` (or
+# `<release>` if it contains `protes`) for the app and `<that name>-mongodb`,
+# `-worker`, `-broker` and `-flower` for MongoDB, the Celery worker, the
+# broker and Flower; `nameOverride` replaces the chart name,
</code_context>
<issue_to_address>
**Distinct releases share resource names**
When two releases in one namespace have names where one contains `protes` and both derive the same app name, such as `prod` and `prod-protes`, the fullname rule gives both releases `prod` and `prod-protes` the app name `prod-protes`, so their worker, database, broker, and other resources also collide. After one release installs, Helm rejects the other release's resources as owned by a different release, preventing both deployments from running in the same namespace.
Derive the fullname so distinct release names cannot collapse to the same value, or reject/document colliding names before rendering resources.
</issue_to_address>
### Comment 6
<location path="deployment/templates/_helpers.tpl" line_range="16" />
<code_context>
+{{- define "protes.settings" -}}
+{{- include "protes.validate" . -}}
+valuesKey: protes
+maxContentLength: 1048576
+requireAudience: true
+mongodb:
</code_context>
<issue_to_address>
**Custom limits are ignored by ingress**
When a deployment sets `config.server.max_content_length` above 1 MiB and uses ingress-nginx, `protes.settings` still passes a 1 MiB limit to the library chart, so ingress-nginx returns 413 for requests the app is configured to accept.
Pass the configured `config.server.max_content_length` to the library chart instead of a fixed 1 MiB.
</issue_to_address>
### Comment 7
<location path="deployment/templates/_helpers.tpl" line_range="17" />
<code_context>
+{{- include "protes.validate" . -}}
+valuesKey: protes
+maxContentLength: 1048576
+requireAudience: true
+mongodb:
+ databases: [taskStore]
</code_context>
<issue_to_address>
**Audience opt-out is rejected**
When a deployment sets `config.security.auth.verify_audience` to `false` and omits `config.security.auth.audience`, `protes.settings` passes `requireAudience: true` to `foca-common.checkSettings`, so rendering rejects a missing audience even when `config.security.auth.verify_audience` is `false`; the app permits that configuration, but the chart cannot be installed with it.
Make the library’s audience requirement conditional on `config.security.auth.verify_audience` being enabled.
</issue_to_address>Sourcery assessment
Needs a human reviewer. 7 findings to address first, and the default Ingress now routes every path, including the admin permissions API that the old chart did not expose; if that endpoint is reachable publicly, an exposed admin credential could be used to change access-control rules. Reverting restores the old routing, but cannot undo access or changes made while the endpoint was exposed.
Blocking findings: deployment/values.yaml:92, deployment/templates/_helpers.tpl:286, deployment/README.md:594, deployment/templates/_helpers.tpl:193, deployment/values.yaml:8, and 2 more
- Detect legacy releases by their claims of volumes as well as their Deployments, as the legacy chart does not keep its claims. - Refuse MONGO_DBNAME in protes.extraEnv: it would move the app to a database that the chart does not provision. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Adapt the chart to task ownership (#250): as the app now refuses to start unless access control is enabled and enforced, rendering fails otherwise, instead of skipping the checks of groups and admins. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Summary
Replaces the Helm chart (2.x/3.0.0) with a thin chart over FOCA's library chart
foca-common0.2.0, following cloud-registry'sdeployment/and FOCA's petstore example:resourcePolicy: keep) and the RabbitMQ broker (StatefulSet with persistence). The app's settings (taskStore, body size limit, audience required) and checks are intemplates/_helpers.tpl.mongodb.auth.existingSecret), the broker (broker.existingSecret,CELERY_BROKER_URL) and Flower (flower.existingSecret,basic-auth) use Secrets of the deployment.protes.extraEnv(KubernetesEnvVars, e.g.,valueFrom.secretKeyRef) is added to the app's and the worker's containers. The library chart has no such value, so the chart adds it to the rendered Deployments (protes.withExtraEnv; the output is unchanged withoutextraEnv). Rendering fails for variables that the chart sets itself, forMONGO_DBNAME(the chart provisionstaskStoreonly), and for duplicates.applicationDomain,clusterType,storageAccessMode,celeryWorker,rabbitmq,*.appName,mongodb.secret,flower.basicAuth), and without the security settings the app needs to start (as in cloud-registry; since feat(access-control)!: own tasks per user #250 also unless access control is enabled and enforced). Upgrading a release that still has Deployments or volume claims of the legacy chart fails, because the upgrade would delete its MongoDB volume.values.schema.json(the library'sapp-values.schema.jsonplusprotes.extraEnvandflower), pinned images (MongoDB 7.0.45, RabbitMQ 4.3.7, Flower 2.0.1). The chartversion(0.0.0) andappVersion(dev) are placeholders that the release workflow (ci!: release from signed version tags #230) sets from the tag.protes.tagreplaces the image helper of ci!: release from signed version tags #230, as the library chart has the sameimage/tagsemantics;celeryWorker.taggoes withceleryWorker(nowworker, always with the app's image).foca-common0.2.0 isn't released yet, so the chart uses afile://dependency on a FOCAdevcommit (# FOCA commit: 2c0cfa6…inChart.yaml).scripts/foca_common.shchecks it out into.foca-common/, which Git ignores.scripts/check_release_pins.pynow also fails for chart dependencies whose repository is missing or is neither OCI nor HTTPS, so this pin can't be released. The switch to the release has been added to build: require FOCA 0.17.0 and foca-common 0.2.0 #246 (now titled like cloud-registry#179).testandtest_mongodbjobs build the chart's dependencies, because GitHub's runners have Helm and the chart tests run there. A newhelmjob ("Check Helm chart", Helm v3.22.1) lints the chart with three sets of values and runs the chart tests. Image publishing waits for it. No required checks are renamed (thedevruleset requires none). The release workflow (release.yaml, ci!: release from signed version tags #230) now builds the library chart before it lints (now with--strictand the CI values) and packages the chart, and checks that the package contains the locked library version, as in cloud-registry.deployment/README.md(the deployment page) is rewritten. Changes indocs/development.md(new "Helm chart" section, pin check),docs/upgrading.md("Helm chart") anddocs/access-control.md(the Ingress now routes all paths, including the permissions API).Verification
helm lint deployment --strict -f deployment/ci/test-values.yaml(also withci/optional-values.yaml, and with MongoDB auth off): passed (Helm v3.22.1)pytest tests/test_chart.py tests/test_foca_common.py tests/test_check_release_pins.py: passedcoverage run -m pytest+coverage report: 525 passed, 1 skipped, 100% (after mergingdevwith ci!: release from signed version tags #230 and feat(access-control)!: own tasks per user #250)pre-commit run --all-files(ruff, mypy, semgrep, gitleaks, actionlint, ast-grep): passedmkdocs build --strict: passedrelease.yaml(copy,scripts/chart_readme.py,helm package): passed; the package containsfoca-common0.2.0actionlinton all workflows: passedDeclined review findings
docs/access-control.mdsays how to block/admin/in front of the cluster. Restricting paths would be a library feature (proposed as a FOCA follow-up).helmjob is not part oftests_passed(adversarial, CI): same as cloud-registry. Thedevruleset requires no checks, and image publishing waits for the job.parseBool, the security checks, the upgrade check; quality, medium): moving them into foca-common is proposed as a follow-up, so that both apps share them.testandtest_mongodb.$contextexpression in the templates (quality): this is the pattern of cloud-registry and the petstore example.prodandprod-protescollide (Helm's standard fullname rule;fullnameOverride). Two more findings were not issues: the library takesconfig.server.max_content_lengthandverify_audience: falseinto account. All are answered in their threads.Open questions
None blocking. Decisions to revisit:
protes.clientCredentials.existingSecret), or keep the genericprotes.extraEnv.protes.extraEnvbelongs in the library chart (proposed as a FOCA follow-up). The chart could then dropprotes.withExtraEnv.Closes #216
🤖 Generated with Claude Code