Skip to content

Commit d0fce92

Browse files
authored
fix(platform): declare the injected _cluster values in system charts (#4102)
## What this PR does Ten charts under `packages/system` read `_cluster`, and `bucket` and `monitoring` also read `_namespace`. The platform injects both through the `cozystack-values` Secret, so installs never notice. Rendering a chart on its own does: `helm template packages/system/kubevirt` dies on `index of untyped nil` before it emits anything, and the `_namespace` readers die on `nil pointer evaluating interface {}.host`. Each of the ten now declares the keys it reads, with an empty default. Injected values merge over chart defaults, so an installed release renders exactly what it rendered before. Checked per chart against a realistic injected `_cluster`/`_namespace`: six came out byte-identical, and the other four differ only in `randAlphaNum` secrets, which also differ between two renders of the same tree. The declaration on its own is not worth much, so every chart also gets a suite that renders with nothing injected. The existing suites all set `_cluster` themselves and cannot see whether `values.yaml` still declares it. Drop a declaration and exactly that chart's suite goes red, with the error its comment quotes; I ran that for all twelve. None of the new suites carries a suite-level `templates:` list, on purpose: that list narrows what helm-unittest renders, and would hide the same breakage in a template added later. `kubevirt-cdi` had no `tests/` and no `test:` target, so it gets both. `etcd-operator` reads `_cluster` too and stays as it is, since its one call site already guards with `| default dict`. `cozystack-basics` already declared the key. Closes #4030. ### Not in this PR No CI job runs `helm lint` or a standalone `helm template`, which is why none of this was red. A gate is worth proposing separately. Its value is narrow though: `_cluster` is always populated on a real install, and eight of these ten already had a suite rendering the affected template with `_cluster` supplied. The two with nothing were `kubevirt`, whose `vm-exportproxy-*` templates no test touched, and `kubevirt-cdi`, which had no tests at all. `helm lint` still exits 1 on `keycloak` and `monitoring` with `chart metadata is missing these dependencies: cozy-lib`. Both carry a `charts/cozy-lib` symlink that `Chart.yaml` never declares. That one is not a two-chart item: 82 charts across `packages/{system,apps,extra,core}` fail lint the same way, which is invisible because no job runs `helm lint`. Separate defect, untouched here. Fifteen charts outside `packages/system` break the same way: `apps/{bucket,foundationdb,harbor,kubernetes,mongodb,nats,opensearch,postgres,vpn}` and `extra/{bootbox,etcd,gateway,info,ingress,seaweedfs}`. `cozy-lib`'s own helpers already guard every access with `| default dict`, so routing those reads through the library would close the class instead of patching fifteen more values files. `kubevirt`'s suite only pins that the routes stay absent with nothing injected. Nothing pins that they show up once `_cluster` selects the service. ### Screenshots No UI change: the diff is ten `values.yaml` files, ten helm-unittest suites, and one package `Makefile`. ### Downstream repositories Walked the trigger map in `docs/agents/contributing.md` file by file against this diff. No package is added, renamed or removed under `packages/apps` or `packages/extra`; `packages/core/platform/values.yaml` is untouched; no variant, bundle, component, release asset, namespace or `ApplicationDefinition` semantic changes; no `values.schema.json` and no version enum moves, so the provider's hand-written schemas and defaults are unaffected; nothing under `hack/` moves and no existing make target changes behaviour. The one `Makefile` edit adds a `test:` target to `packages/system/kubevirt-cdi`, matching the target the other nine already have, so `make generate` and the ccp skills that drive it see nothing new. - [x] No downstream repository is affected by this change - [ ] [cozystack/website](https://github.com/cozystack/website) - follow-up: - [ ] [cozystack/terraform-provider-cozystack](https://github.com/cozystack/terraform-provider-cozystack) - follow-up: - [ ] [cozystack/ansible-cozystack](https://github.com/cozystack/ansible-cozystack) - follow-up: - [ ] [cozystack/ccp](https://github.com/cozystack/ccp) - follow-up: - [ ] [cozystack/talm](https://github.com/cozystack/talm) - follow-up: - [ ] [cozystack/cozyhr](https://github.com/cozystack/cozyhr) - follow-up: - [ ] [cozystack/cozy-proxy](https://github.com/cozystack/cozy-proxy) - follow-up: - [ ] [cozystack/cozystack-telemetry-server](https://github.com/cozystack/cozystack-telemetry-server) - follow-up: - [ ] [cozystack/external-apps-example](https://github.com/cozystack/external-apps-example) - follow-up: - [ ] [cozystack/examples](https://github.com/cozystack/examples) - follow-up: - [ ] [cozystack/community](https://github.com/cozystack/community) - follow-up: ### Release note ```release-note fix(platform): declare the platform-injected `_cluster` and `_namespace` values in the ten system charts that read them, so each chart renders with `helm template` outside a cluster instead of failing on a nil map. No change to what an installed release renders. ``` <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit - **Bug Fixes** - Improved standalone Helm chart rendering when platform-provided values are unavailable. - Prevented rendering failures across system charts, including bucket, dashboard, Keycloak, monitoring, KubeVirt, and related components. - **Tests** - Added comprehensive standalone rendering coverage for system charts. - Added validation for expected ingress, gateway, TLS route, and resource output under different configuration scenarios. - Added a chart test command for KubeVirt CDI. <!-- end of auto-generated comment: release notes by coderabbit.ai -->
2 parents 6751633 + eef5fe6 commit d0fce92

21 files changed

Lines changed: 296 additions & 0 deletions

File tree

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
suite: bucket renders with no platform values injected
2+
release:
3+
name: bucket
4+
namespace: cozy-bucket
5+
6+
# The platform injects _cluster and _namespace through the cozystack-values
7+
# Secret, so every case that sets them itself renders fine whether or not
8+
# values.yaml declares the keys. This case supplies neither. Drop the
9+
# _cluster declaration and the render dies on "index of untyped nil"; drop
10+
# the _namespace one and it dies on "nil pointer evaluating interface
11+
# {}.host". Both are what keep the chart renderable outside a cluster. No
12+
# suite-level `templates:` list here on purpose: it would narrow the render
13+
# to the listed files and let a later template reintroduce the same
14+
# breakage unseen.
15+
16+
tests:
17+
- it: still renders the ingress when _cluster and _namespace are absent
18+
asserts:
19+
- template: templates/ingress.yaml
20+
hasDocuments:
21+
count: 1

‎packages/system/bucket/values.yaml‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,7 @@
1+
# Injected by the platform from the cozystack-values Secret. The empty
2+
# defaults keep the chart renderable on its own, outside a cluster.
3+
_cluster: {}
4+
_namespace: {}
5+
16
bucketName: "cozystack"
27
users: {}
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
suite: cert-manager-issuers renders with no platform values injected
2+
release:
3+
name: cert-manager-issuers
4+
namespace: cozy-cert-manager
5+
6+
# The platform injects _cluster through the cozystack-values Secret, so every
7+
# case that sets it itself renders fine whether or not values.yaml declares
8+
# the key. This case supplies nothing. Drop the declaration from values.yaml
9+
# and the render dies on "index of untyped nil" before a single assert runs;
10+
# the declaration is the only thing keeping the chart renderable outside a
11+
# cluster. No suite-level `templates:` list here on purpose: it would narrow
12+
# the render to the listed files and let a later template reintroduce the
13+
# same breakage unseen.
14+
15+
tests:
16+
- it: still renders the cluster issuers when _cluster is absent
17+
asserts:
18+
- template: templates/cluster-issuers.yaml
19+
hasDocuments:
20+
count: 3
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,6 @@
1+
# Injected by the platform from the cozystack-values Secret. The empty
2+
# default keeps the chart renderable on its own, outside a cluster.
3+
_cluster: {}
4+
15
cert-manager:
26
installCRDs: true
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
suite: cozystack-api renders with no platform values injected
2+
release:
3+
name: cozystack-api
4+
namespace: cozy-system
5+
6+
# The platform injects _cluster through the cozystack-values Secret, so every
7+
# case that sets it itself renders fine whether or not values.yaml declares
8+
# the key. This case supplies nothing. Drop the declaration from values.yaml
9+
# and the render dies on "index of untyped nil" before a single assert runs;
10+
# the declaration is the only thing keeping the chart renderable outside a
11+
# cluster. No suite-level `templates:` list here on purpose: it would narrow
12+
# the render to the listed files and let a later template reintroduce the
13+
# same breakage unseen.
14+
15+
tests:
16+
- it: exposes nothing when _cluster is absent
17+
asserts:
18+
- template: templates/api-ingress.yaml
19+
hasDocuments:
20+
count: 0
21+
- template: templates/api-tlsroute.yaml
22+
hasDocuments:
23+
count: 0
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
# Injected by the platform from the cozystack-values Secret. The empty
2+
# default keeps the chart renderable on its own, outside a cluster.
3+
_cluster: {}
4+
15
cozystackAPI:
26
image: ghcr.io/cozystack/cozystack/cozystack-api:v1.6.0@sha256:c4d374a9bc5e6f6e66d24b29396f1eae9d7f06fd268ff767d05c45ca35e84e2e
37
replicas: 2
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
suite: dashboard renders with no platform values injected
2+
release:
3+
name: dashboard
4+
namespace: cozy-dashboard
5+
6+
# The platform injects _cluster through the cozystack-values Secret, so every
7+
# case that sets it itself renders fine whether or not values.yaml declares
8+
# the key. This case supplies nothing. Drop the declaration from values.yaml
9+
# and the render dies on "index of untyped nil" before a single assert runs;
10+
# the declaration is the only thing keeping the chart renderable outside a
11+
# cluster. No suite-level `templates:` list here on purpose: it would narrow
12+
# the render to the listed files and let a later template reintroduce the
13+
# same breakage unseen.
14+
15+
tests:
16+
- it: exposes nothing when _cluster is absent
17+
asserts:
18+
- template: templates/ingress.yaml
19+
hasDocuments:
20+
count: 0
21+
- template: templates/httproute.yaml
22+
hasDocuments:
23+
count: 0

‎packages/system/dashboard/values.yaml‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
# Injected by the platform from the cozystack-values Secret. The empty
2+
# default keeps the chart renderable on its own, outside a cluster.
3+
_cluster: {}
4+
15
console:
26
image: ghcr.io/cozystack/cozystack/cozystack-ui:v1.6.0@sha256:ad0e132ce506bbc9e0f6a5dfb94311c9bbc08da3d8eca84eb0e527ba6c1a8897
37
tokenProxy:
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
suite: keycloak-configure renders with no platform values injected
2+
release:
3+
name: keycloak-configure
4+
namespace: cozy-keycloak
5+
6+
# The platform injects _cluster through the cozystack-values Secret, so every
7+
# case that sets it itself renders fine whether or not values.yaml declares
8+
# the key. This case supplies nothing. Drop the declaration from values.yaml
9+
# and the render dies on "index of untyped nil" before a single assert runs;
10+
# the declaration is the only thing keeping the chart renderable outside a
11+
# cluster. No suite-level `templates:` list here on purpose: it would narrow
12+
# the render to the listed files and let a later template reintroduce the
13+
# same breakage unseen.
14+
15+
tests:
16+
- it: still renders the realm objects when _cluster is absent
17+
asserts:
18+
- template: templates/configure-kk.yaml
19+
hasDocuments:
20+
count: 6

‎packages/system/keycloak-configure/values.yaml‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
# Injected by the platform from the cozystack-values Secret. The empty
2+
# default keeps the chart renderable on its own, outside a cluster.
3+
_cluster: {}
4+
15
# Keycloak image used by the one-shot admin-API job that enables the
26
# UPDATE_EMAIL required action. Only kcadm.sh is used, so it just needs
37
# to track the Keycloak server major version (packages/system/keycloak).

0 commit comments

Comments
 (0)