Files
cozystack/packages/core/platform/Makefile
Andrey KolkovandClaude Opus 4.8 ba32df69c0 feat(backups): add RabbitMQ definitions backup via a dedicated strategy driver
RabbitMQ's cluster operator ships no backup CRD and RabbitMQ has no
consistent online export of message payloads, so back up broker
DEFINITIONS (vhosts, users, permissions, queues, exchanges, bindings,
policies, parameters) over the management HTTP API and store them in the
system bucket. Message payloads and PITR are out of scope - a full-data
backup is a Velero volume snapshot, a separate strategy.

Add a first-class strategy.backups.cozystack.io/Rabbitmq driver, following
the Altinity pattern (a dedicated driver that renders a one-shot Job for an
HTTP-API engine):

  - reconcileRabbitmq / reconcileRabbitmqRestore render the strategy's
    PodTemplateSpec (curl GET/POST /api/definitions, push/pull to S3 with
    --aws-sigv4) as a batch/v1.Job, for both in-place and to-copy restore.
  - A Go-read precondition gates each run on the RabbitmqCluster reporting
    AllReplicasReady (via the rabbitmqtypes partial type), surfacing a
    precise Ready=False wait instead of a Job that starts and fails.
  - The produced Backup records the object location on status.artifact.uri
    (rendered from spec.artifactURITemplate; the Backup CRD has no status
    subresource, so it persists on Create, as in the Etcd driver).

Wire dispatch in both controllers + supportedBackupStrategyKinds, register
rabbitmqtypes in the scheme, and grant read on rabbitmqclusters. Ship
cozy-default-rabbitmq (a $bucketName-gated Rabbitmq strategy) and route
apps.cozystack.io/RabbitMQ to it in the cozy-default BackupClass. The
application chart is untouched.

Add unit tests for the driver's pure helpers and the precondition gate, a
runnable example, and an honest-roundtrip Chainsaw e2e that seeds a
sentinel vhost, backs it up, drops it, and asserts it round-trips through
object storage on both restore flows.

The Job pod reuses the platform-migrations image (curl + ca-certificates)
under a new rabbitmqBackupClientImage key, stamped in lockstep with
chBackupClientImage so the repository stays pinned at one digest; a
dedicated slim image is a follow-up.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Signed-off-by: Andrey Kolkov <androndo@gmail.com>
2026-09-01 18:21:10 +04:00

67 lines
3.1 KiB
Makefile

NAME=cozystack-platform
NAMESPACE=cozy-system
include ../../../hack/common-envs.mk
test:
helm unittest .
show:
cozyhr show --namespace $(NAMESPACE) $(NAME)
apply:
cozyhr apply --namespace $(NAMESPACE) $(NAME)
reconcile: apply
diff:
cozyhr diff --namespace $(NAMESPACE) $(NAME)
# Strip the platform.cozystack.io/no-delete label from every guarded object so
# `helm uninstall cozy-platform` (and ad-hoc deletes of protected resources)
# is no longer denied by the deletion-protection VAP. After this runs, the
# cluster has no guardrail until the next `helm upgrade` re-stamps the label.
# Intended for teardown / disaster-recovery, not routine use.
unprotect:
hack/unprotect.sh
image: image-migrations
image-migrations:
# Vendor the v1alpha2 CRDs into the build context so migration 50 can ensure
# they exist before adoption (the etcd-operator-crds HelmRelease only installs
# AFTER this pre-upgrade hook). Copied from the committed source of truth —
# no build-time network fetch, stays in lockstep with the chart. Removed again
# after the build; the leading rm reclaims a stale copy from a failed build.
rm -rf images/migrations/etcd-operator-crds
mkdir -p images/migrations/etcd-operator-crds
cp ../../system/etcd-operator-crds/templates/*.yaml images/migrations/etcd-operator-crds/
docker buildx build images/migrations \
$(call image-tags,platform-migrations,v$(COZYSTACK_VERSION)) \
$(call cache-args,platform-migrations) \
--metadata-file images/migrations.json \
$(BUILDX_ARGS)
rm -rf images/migrations/etcd-operator-crds
# Stamp BOTH consumers of this image. backupstrategy-controller renders it
# into the Altinity strategy Pod as a curl+jq runner — a WORKAROUND, not a
# design: that Pod needs only curl/jq/sleep/date but gets 349 MB including
# kubectl, helm and etcd-migrate, and this image's ENTRYPOINT is the
# migration runner itself. It should get a dedicated ~23 MB image owned by
# its own package, which would delete this cross-package stamp; see the TODO
# in ../../system/backupstrategy-controller/values.yaml.
#
# Until then the two pins MUST move together. The second copy had no
# producer, so it silently froze at v1.4.0-rc.2 while this one advanced, and
# a promotion then tried to retag two different digests to the same stable
# tag — which the write-once guard in hack/promote-retag.sh turns into a
# failed release. hack/image-pin-consistency.bats keeps them in lockstep.
IMAGE="$(REGISTRY)/platform-migrations:$(IMAGE_TAG)@$$(yq -e -o json -r '.["containerimage.digest"]' images/migrations.json)" \
yq --inplace '.migrations.image = strenv(IMAGE)' values.yaml
IMAGE="$(REGISTRY)/platform-migrations:$(IMAGE_TAG)@$$(yq -e -o json -r '.["containerimage.digest"]' images/migrations.json)" \
yq --inplace '.backupStrategyController.chBackupClientImage = strenv(IMAGE)' \
../../system/backupstrategy-controller/values.yaml
IMAGE="$(REGISTRY)/platform-migrations:$(IMAGE_TAG)@$$(yq -e -o json -r '.["containerimage.digest"]' images/migrations.json)" \
yq --inplace '.backupStrategyController.rabbitmqBackupClientImage = strenv(IMAGE)' \
../../system/backupstrategy-controller/values.yaml
rm -f images/migrations.json