Files
cozystack/packages/system/backupstrategy-controller/values.yaml
T
Mattia Eleuteri c6fc034fed fix(backupstrategy-controller): repair the bucket credentials Secret from the gate, not a chart fail
Addresses the four findings on #3524.

**The `fail` in the bucket chart (MAJOR).** The <bucket>-<user>-credentials
Secret was made to `fail` the render while its COSI lookup was empty, so the
release would retry and converge instead of skipping the Secret permanently.
Helm cannot render a partial set, so that fail aborts the WHOLE
<bucket>-system release: the other users' Secrets, and the bucket UI
Deployment/Service/Ingress/HTTPRoute with them. One declared user whose
BucketAccess never provisions takes down every other user of that bucket,
and on an already-installed release parks it in Failed, blocking every later
upgrade.

**No per-bucket escape (MAJOR).** Rather than add one, remove the need for
it. The gate already forces the release that renders the lookup-gated
Strategy CRs; the credentials Secret is the same trap one release earlier,
and the gate reads that Secret to resolve the bucket name in the first
place. So while it is absent, or carries no bucket name, force the bucket's
<bucket>-system release instead of doing nothing. That cannot deadlock its
own precondition: the BucketClaim and the BucketAccess whose COSI Secret the
lookup reads are rendered unconditionally by the parent release, not by the
one being forced.

The two releases are throttled independently — they are forced in sequence
on a bootstrap, so a shared timestamp would delay the second by a full
MinForceInterval for no reason. Coordinates come from the chart under
provisionBucket, and are omitted on external S3 where the Secret is
admin-managed and no release renders it. No RBAC delta: patch on
helmreleases is already cluster-scoped.

The chart goes back to a partial render, with the comment now explaining why
the skip is not self-healing and why failing is the wrong lever, and a test
that renders the UI with every user unresolvable so a reintroduced `fail`
fails the suite. Tenant buckets keep their pre-existing behaviour;
generalising the repair to every bucket needs a controller that owns them
and is tracked separately.

**Stale gauge (MINOR).** cozystack_backup_default_objects_missing was only
written on the happy path, so the state the gate exists to catch reported 0
and the documented alert never fired. It is now written on the unresolved
path too — the credentials Secret counts as one of the objects the default
backups depend on, which is what it always was. On an API error the gauge is
deliberately left alone rather than flapping, so a new
cozystack_backup_default_objects_check_errors_total marks it stale, and the
doc pairs the two instead of overstating the gauge.

**Suspended releases (MINOR).** forceHelmRelease now does a point Get and
skips a release with spec.suspend: true. helm-controller ignores forceAt and
requestedAt while suspended (`cozyhr suspend` sets exactly that), so the gate
was re-stamping every MinForceInterval for the whole suspension and climbing
the force counter — which the runbook attributes to a render that is not
producing the objects, the wrong diagnosis. The skip is logged and not
counted, so a climbing counter keeps its documented meaning.

Reported-by: IvanHunters <xorokhotnikov@gmail.com>
Signed-off-by: Mattia Eleuteri <mattia@hidora.io>
Assisted-By: Claude <noreply@anthropic.com>
(cherry picked from commit f859b710a4)
2026-08-10 10:10:34 +00:00

180 lines
11 KiB
YAML

backupStrategyController:
image: "ghcr.io/cozystack/cozystack/backupstrategy-controller:v1.6.1@sha256:7cb5af7bd8fae2ef5d6e58d1eb6eb7d9579bff8df228ac3d936c6e14ae5e063f"
# chBackupClientImage is the image rendered into the Altinity strategy
# Pod: it drives clickhouse-backup's HTTP API via curl + jq.
#
# WORKAROUND — platform-migrations is the wrong image for this job and
# should be replaced by a dedicated one (see the TODO below). It is
# reused here only because it happens to bundle curl + jq, and this
# release could not absorb a new image. What that reuse actually costs:
# - the strategy script needs exactly curl, jq, sleep and date, yet
# this image is 349 MB carrying kubectl, helm, git, cozyhr and the
# etcd-migrate binary into a tenant-adjacent backup Pod;
# - its ENTRYPOINT is run-migrations.sh, so only the `command:`
# override in strategy-altinity-default.yaml stands between this Pod
# and running platform migrations with kubectl and helm on the PATH;
# - it couples the backup client to migrations: bumping
# ETCD_OPERATOR_VERSION or editing any migration script re-digests
# this image, forcing this pin to move for reasons that have nothing
# to do with backups. That coupling is what broke — see below.
#
# TODO: replace with a dedicated ch-backup-client image built by THIS
# package's own Makefile (alpine + curl + jq + ca-certificates measures
# 23 MB, 15x smaller). That also removes the cross-package stamp
# entirely, because the pin would then be produced by the package that
# owns it. The often-cited objection — "a second tag release CI must
# re-digest each cut" — is not the real cost: every other first-party
# image already pays it, automatically. The real defect was a pin with
# NO producer, which a package-owned image cannot reproduce.
#
# DO NOT hand-edit: packages/core/platform/Makefile stamps this key with
# the same ref it writes to .migrations.image there, so the two stay in
# lockstep by construction. They previously did not — this key had no
# producer at all and froze at v1.4.0-rc.2 while the other advanced to
# v1.5.0. Two digests under one repository means a promotion tries to
# retag both to the same stable tag, and the write-once guard in
# hack/promote-retag.sh fails the release. hack/image-pin-consistency.bats
# asserts no repository is pinned at more than one digest.
chBackupClientImage: "ghcr.io/cozystack/cozystack/platform-migrations:v1.6.1@sha256:a34e7156a52dc55b27662917e5f9d5bbea671188d8db233296d0a98c800dc6c6"
replicas: 2
debug: false
metrics:
enabled: true
bindAddress: ":8443"
resources:
requests:
cpu: 10m
memory: 64Mi
limits:
cpu: 500m
memory: 128Mi
# backupStorage describes the platform-managed S3 bucket used by every
# default BackupClass strategy. The bucket lives in the backupStorage.namespace
# (tenant-root by default) and is provisioned through the apps.cozystack.io/Bucket CR.
# Tenants never see these coordinates directly — they reference cozy-default
# BackupClass and the backupstrategy-controller projects credentials per BackupJob.
backupStorage:
# provisionBucket controls whether to create the apps.cozystack.io/Bucket CR.
# Set to false when the cluster runs against an external S3 (no SeaweedFS)
# and the admin manages the credentials Secret manually.
provisionBucket: true
# The Bucket CR lives in tenant-root (a tenant namespace) because the
# apps.cozystack.io/Bucket chart's RBAC helper fails Helm render on any
# namespace that does not start with "tenant-" (see
# packages/library/cozy-lib/templates/_rbac.tpl). tenant-root is the
# root tenant present on every Cozystack install, so the system Bucket
# naturally lives there. Cross-namespace Secret read is granted to the
# backupstrategy-controller via cluster-scoped Secret RBAC.
namespace: tenant-root
bucketName: cozy-backups
# bucketNameOverride is an escape hatch for offline `helm template`
# renders (CI / local diffs). When set, the chart skips the live-cluster
# BucketClaim status lookup and uses this string as the S3 bucket name.
# Leave empty in production — the COSI driver assigns its own bucket
# name independent of .bucketName above, and the BucketClaim status
# is the only authoritative source.
bucketNameOverride: ""
# endpoint is the S3 endpoint URL shared by every default Strategy CR, the
# Velero BSL and the controller Deployment. For a provisioned bucket
# (provisionBucket: true, the default) it is NOT used verbatim: the
# "backupstrategy-controller.endpoint" helper derives the real endpoint from
# the COSI bucket's system credentials Secret (backupStorage.systemSecretName)
# and forces https://, because Cozystack's SeaweedFS runs with
# enableSecurity=true and serves TLS on :8333 behind the self-signed
# "SeaweedFS CA". The COSI-advertised endpoint is the external S3 ingress
# (ACME cert), which every consumer can verify — unlike the in-cluster
# service, whose CA is not plumbed to the backup operators and which the Etcd
# Strategy's S3 schema (no caCert field) cannot target at all.
#
# This value is the FALLBACK, used only when the derivation cannot run:
# - provisionBucket: false (external S3) — set it to your S3 endpoint,
# scheme included; it is used verbatim (the MariaDB/FDB strategies compute
# their secure flag from the scheme, so https:// enables TLS there — make
# the CA bundle reachable to those operators before pointing at a
# self-signed external endpoint);
# - offline `helm template` / unit renders and the pre-reconcile first
# install, where the Secret lookup returns nothing.
endpoint: http://seaweedfs-s3.tenant-root.svc.cozy.local:8333
# region is re-projected into cozy-backups-creds on the next reconcile
# (1-minute tick for system namespaces, on-demand for tenant namespaces).
# However, charts that consume the region via secretKeyRef in env vars —
# the chart-emitted ClickHouse sidecar on `useSystemBucket: true` is the
# only such consumer today — only pick up the new value on Pod restart.
# Plan a rollout of those Pods when you change this value.
region: us-east-1
forcePathStyle: true
# systemSecretName — the human-friendly Secret produced by the Bucket
# application in the backupStorage.namespace (tenant-root by default). The Bucket release is
# wrapped with the bucket-rd "bucket-" prefix (see
# packages/system/bucket-rd/cozyrds/bucket.yaml), so the human-friendly
# Secret rendered by packages/system/bucket/templates/user-credentials.yaml
# is named <bucket-release>-<user>-credentials. The projector also
# tolerates the raw COSI Secret format (single BucketInfo JSON key) so a
# cluster that wires an external S3 Secret manually still works.
systemSecretName: bucket-cozy-backups-system-credentials
# systemNamespaces — namespaces where the controller eagerly projects
# cozy-backups-creds so long-lived static references (Velero BSL, FDB
# operator deployments) keep finding the Secret without on-demand
# rendering. Tenants are projected lazily during BackupJob reconcile.
systemNamespaces:
- cozy-velero
# reconcileDefaultObjects enables the controller's DefaultObjectsGate.
#
# The Strategy CRs and the Velero BSL below are Helm-templated behind a
# `lookup` of the BucketClaim THIS chart creates, because the S3 bucket
# name is assigned by the COSI driver (bucket-<claim-UID>) and cannot be
# computed at render time. On a fresh install the lookup is empty and those
# templates render nothing — and helm-controller does not re-render a
# release whose chart and values did not change (drift detection is off on
# operator-generated HelmReleases), so the skip is PERMANENT. Clusters have
# run for months with only the BackupClass present and no Strategy CRs at
# all; recovery needed a hand-stamped reconcile.fluxcd.io/forceAt +
# requestedAt, because a plain reconcile request does not re-render.
#
# The systemSecretName Secret above sits one release earlier in the same
# trap: packages/system/bucket/templates/user-credentials.yaml renders it
# behind a `lookup` of the COSI Secret, and skips it just as permanently.
# Without it the projector has no source at all, so nothing downstream can
# resolve — and neither can this gate, which reads the bucket name from it.
#
# With this enabled the controller repairs both, in order: while the
# credentials Secret is missing it forces the bucket's <bucket>-system
# release; once the bucket name resolves it checks that every object
# cozy-default routes to exists and forces THIS release when any is
# missing. Both are throttled, independently, and a no-op in the steady
# state. A suspended release is skipped rather than re-stamped forever. The
# gate does NOT create the objects itself: their bodies are values-driven
# and Helm stays their single owner.
#
# Turn this off only if you manage the default Strategy CRs out of band and
# accept that a missed install-time render is never repaired. Watch
# cozystack_backup_default_objects_missing (paired with
# cozystack_backup_default_objects_check_errors_total, which marks the
# gauge stale) if you do.
reconcileDefaultObjects: true
# velero — BSL rendering. The cozy-default BackupStorageLocation is
# created in cozy-velero by templates/velero-bsl.yaml so endpoint/bucket/
# region come from the same backupStorage block used by Strategy CRs and
# the projector, eliminating drift.
#
# bslEnabled defaults to TRUE because cozystack.velero is a hard
# dependsOn for this PackageSource (see
# packages/core/platform/sources/backupstrategy-controller.yaml) — the
# Velero CRDs are guaranteed to exist by the time this chart installs.
# The BSL template additionally gates itself on a populated BucketClaim
# status via the bucketName helper, so on a bootstrap install the BSL
# materialises only after the platform Bucket reconciles AND the
# DefaultObjectsGate has forced a real Helm upgrade (an interval reconcile
# alone does not re-render). Setting this
# to false is an explicit opt-out for clusters that disable VM backups
# entirely and want to avoid the cluster-default BSL. In that case the
# cozy-default-velero-vminstance / -vmdisk Strategy CRs are gated off the
# same flag and are NOT rendered either, so the DefaultObjectsGate does
# not expect them (it would otherwise force a Helm upgrade forever against
# a render that can never produce them). VM BackupJobs against cozy-default
# still fail, because the BackupClass keeps routing VMInstance / VMDisk to
# those absent strategies.
velero:
bslEnabled: true
namespace: cozy-velero