Skip to content

Commit 62a43b5

Browse files
androndoclaude
andcommitted
fix(platform): forward backupStorage overrides to the backupstrategy-controller Package (#3245)
The documented admin override for the cozy-default backup S3 coordinates (spec.components.backupstrategy-controller.values on the cozystack.cozystack-platform Package) had no effect: that PackageSource exposes only the platform component, so the operator silently ignored the block, and nothing in the platform chart forwarded backupStorage to the child Package. Wire it the same way bundles/iaas.yaml forwards kubevirt / gpu-operator values: a new top-level backupStorage value on the platform chart is rendered into the emitted cozystack.backupstrategy-controller Package CR as components.backupstrategy-controller.values.backupStorage, from where the cozystack operator merges it into the backupstrategy-controller HelmRelease over the chart defaults. When backupStorage is unset the emitted Package is unchanged. Update docs/operations/backup-classes.md to the working override path (spec.components.platform.values.backupStorage) and call out the two plausible-looking paths that do not work. Add a helm-unittest suite covering the no-op default and the forwarding on isp-full and isp-full-generic. Fixes #3245 Assisted-By: Claude <[email protected]> Co-Authored-By: Claude Fable 5 <[email protected]> Signed-off-by: Andrey Kolkov <[email protected]>
1 parent cc66e22 commit 62a43b5

4 files changed

Lines changed: 106 additions & 3 deletions

File tree

‎docs/operations/backup-classes.md‎

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ Alert on `rate(failures_total) > 0` or `absent_over_time(successes_total[10m])`
108108

109109
## Admin overrides for `cozy-default`
110110

111-
`cozy-default` is rendered by the `backupstrategy-controller` chart and owned by Flux's helm-controller. **Direct `kubectl edit backupclass cozy-default` is overwritten on the next helm reconcile** — the same applies to its companion `strategy.backups.cozystack.io/*` CRs (`cozy-default-cnpg`, `cozy-default-etcd`, `cozy-default-mariadb`, `cozy-default-altinity`, `cozy-default-foundationdb`, the two `cozy-default-velero-*`). The supported override path is the cozystack `Package` CR, which lets admins inject Helm values into platform components:
111+
`cozy-default` is rendered by the `backupstrategy-controller` chart and owned by Flux's helm-controller. **Direct `kubectl edit backupclass cozy-default` is overwritten on the next helm reconcile** — the same applies to its companion `strategy.backups.cozystack.io/*` CRs (`cozy-default-cnpg`, `cozy-default-etcd`, `cozy-default-mariadb`, `cozy-default-altinity`, `cozy-default-foundationdb`, the two `cozy-default-velero-*`). The supported override path is the `backupStorage` block on the **`platform` component** of the `cozystack.cozystack-platform` Package CR:
112112

113113
```yaml
114114
apiVersion: cozystack.io/v1alpha1
@@ -117,7 +117,7 @@ metadata:
117117
name: cozystack.cozystack-platform
118118
spec:
119119
components:
120-
backupstrategy-controller:
120+
platform:
121121
values:
122122
backupStorage:
123123
provisionBucket: true # default; set false for external S3
@@ -130,6 +130,8 @@ spec:
130130
- cozy-velero
131131
```
132132

133+
The platform chart forwards this block into the child `Package cozystack.backupstrategy-controller` as `components.backupstrategy-controller.values.backupStorage` (`packages/core/platform/templates/bundles/system.yaml`), from where the cozystack operator merges it into the `backupstrategy-controller` HelmRelease over the chart defaults. Two paths that look plausible do **not** work: `spec.components.backupstrategy-controller` on the `cozystack.cozystack-platform` Package is silently ignored (the only component under that PackageSource is `platform`), and patching the child `Package cozystack.backupstrategy-controller` directly is reverted whenever the platform helm-reconcile re-renders it.
134+
133135
| Knob | Effect |
134136
|---|---|
135137
| `provisionBucket` | Toggle creation of the in-cluster `apps.cozystack.io/Bucket` CR. Set `false` for external S3 (see [Disabling the platform-managed bucket](#disabling-the-platform-managed-bucket)). |

‎packages/core/platform/templates/bundles/system.yaml‎

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -216,7 +216,21 @@
216216
{{- end }}
217217
{{include "cozystack.platform.package.default" (list "cozystack.etcd-application" $) }}
218218
{{include "cozystack.platform.package.default" (list "cozystack.cozystack-basics" $) }}
219-
{{include "cozystack.platform.package.default" (list "cozystack.backupstrategy-controller" $) }}
219+
{{- /*
220+
Forward admin backupStorage overrides (endpoint, region, systemSecretName, …)
221+
into the emitted cozystack.backupstrategy-controller Package CR's
222+
components.backupstrategy-controller.values, so the supported override path
223+
on the cozystack-platform Package — spec.components.platform.values.backupStorage —
224+
actually reaches the backupstrategy-controller HelmRelease (#3245). Same
225+
pattern as the kubevirt / gpu-operator forwarding in bundles/iaas.yaml. The
226+
components block is only rendered when the admin set something, so an unset
227+
backupStorage keeps the emitted Package identical to the historical render.
228+
*/ -}}
229+
{{- $backupStrategyComponents := dict -}}
230+
{{- if .Values.backupStorage -}}
231+
{{- $_ := set $backupStrategyComponents "backupstrategy-controller" (dict "values" (dict "backupStorage" .Values.backupStorage)) -}}
232+
{{- end -}}
233+
{{include "cozystack.platform.package" (list "cozystack.backupstrategy-controller" "default" $ $backupStrategyComponents) }}
220234
{{include "cozystack.platform.package.default" (list "cozystack.backup-controller" $) }}
221235
{{- /* velero must be a default package: backupstrategy-controller (default)
222236
hard-depends on cozystack.velero, so an optional velero leaves the
Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
suite: bundles.system backupStorage → backupstrategy-controller wiring
2+
templates:
3+
- templates/bundles/system.yaml
4+
release:
5+
name: cozystack
6+
namespace: cozy-system
7+
tests:
8+
# Regression for #3245: the documented admin override for the cozy-default
9+
# backup S3 coordinates rides on spec.components.platform.values.backupStorage
10+
# of the cozystack-platform Package. The platform chart must forward that
11+
# block into the emitted cozystack.backupstrategy-controller Package CR's
12+
# components, otherwise the override silently never reaches the
13+
# backupstrategy-controller HelmRelease.
14+
- it: emits cozystack.backupstrategy-controller without a components block when backupStorage is unset
15+
set:
16+
bundles:
17+
system:
18+
enabled: true
19+
variant: isp-full
20+
documentSelector:
21+
path: metadata.name
22+
value: cozystack.backupstrategy-controller
23+
asserts:
24+
- equal:
25+
path: kind
26+
value: Package
27+
- equal:
28+
path: spec.variant
29+
value: default
30+
- notExists:
31+
path: spec.components
32+
33+
- it: forwards backupStorage overrides into the backupstrategy-controller component values
34+
set:
35+
bundles:
36+
system:
37+
enabled: true
38+
variant: isp-full
39+
backupStorage:
40+
provisionBucket: false
41+
endpoint: https://s3.example.com
42+
region: eu-central-1
43+
systemSecretName: external-s3-credentials
44+
documentSelector:
45+
path: metadata.name
46+
value: cozystack.backupstrategy-controller
47+
asserts:
48+
- equal:
49+
path: spec.components.backupstrategy-controller.values.backupStorage.provisionBucket
50+
value: false
51+
- equal:
52+
path: spec.components.backupstrategy-controller.values.backupStorage.endpoint
53+
value: https://s3.example.com
54+
- equal:
55+
path: spec.components.backupstrategy-controller.values.backupStorage.region
56+
value: eu-central-1
57+
- equal:
58+
path: spec.components.backupstrategy-controller.values.backupStorage.systemSecretName
59+
value: external-s3-credentials
60+
61+
- it: forwards backupStorage overrides on the isp-full-generic variant too
62+
set:
63+
bundles:
64+
system:
65+
enabled: true
66+
variant: isp-full-generic
67+
backupStorage:
68+
endpoint: https://s3.example.com
69+
documentSelector:
70+
path: metadata.name
71+
value: cozystack.backupstrategy-controller
72+
asserts:
73+
- equal:
74+
path: spec.components.backupstrategy-controller.values.backupStorage.endpoint
75+
value: https://s3.example.com

‎packages/core/platform/values.yaml‎

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -425,6 +425,18 @@ monitoring:
425425
# here is true only to preserve the historical always-create behaviour;
426426
# operators MUST set it to match their actual Tenant/root spec.monitoring.
427427
rootEnabled: true
428+
# Backup storage overrides for the platform-managed cozy-default BackupClass.
429+
# Everything set here is forwarded verbatim into the emitted
430+
# cozystack.backupstrategy-controller Package CR as
431+
# components.backupstrategy-controller.values.backupStorage, so it lands on the
432+
# backupstrategy-controller HelmRelease and deep-merges over that chart's own
433+
# backupStorage defaults (packages/system/backupstrategy-controller/values.yaml
434+
# documents every knob: provisionBucket, bucketName, endpoint, region,
435+
# forcePathStyle, systemSecretName, systemNamespaces, …). Admins set this via
436+
# spec.components.platform.values.backupStorage on the
437+
# cozystack.cozystack-platform Package — see docs/operations/backup-classes.md.
438+
# Empty (the default) forwards nothing and keeps the child chart defaults.
439+
backupStorage: {}
428440
# Pod scheduling configuration
429441
scheduling:
430442
globalAppTopologySpreadConstraints: ""

0 commit comments

Comments
 (0)