mirror of
https://github.com/cozystack/cozystack.git
synced 2026-11-14 00:23:54 +09:00
The rabbitmq backup roundtrip was the only backup e2e routing through the platform cozy-default system bucket, whose advertised endpoint in the CI sandbox is the unroutable s3.example.org placeholder, so the backup Job failed with "Could not resolve host: s3.example.org". Mirror the clickhouse/mariadb backup examples: provision a demo Bucket, project its access keys into rabbitmq-backup-creds and copy the seaweedfs CA into rabbitmq-backup-ca, and render a self-contained Rabbitmq strategy + rabbitmq-default BackupClass whose curl uploads to the in-cluster seaweedfs endpoint (S3_ENDPOINT override, CURL_CA_BUNDLE for the self-signed cert). The in-Pod script is kept identical to the shipped cozy-default-rabbitmq strategy, which is left unchanged; the demo only reuses its client image. Assisted-By: LLM Signed-off-by: Andrey Kolkov <androndo@gmail.com>
40 lines
2.1 KiB
Bash
Executable File
40 lines
2.1 KiB
Bash
Executable File
#!/bin/bash
|
|
# Idempotent teardown of the RabbitMQ backup demo. Removes only this demo's
|
|
# objects — never a blanket --all — so it is safe to run before a re-run and in
|
|
# a chainsaw finally step. Order: restore/backup jobs and Plan, then this demo's
|
|
# Backup artifacts, then the applications, then the demo's Bucket + strategy +
|
|
# BackupClass + Secrets. The platform cozy-backups bucket and cozy-default-rabbitmq
|
|
# strategy are platform-owned and left alone.
|
|
set -uo pipefail
|
|
|
|
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
|
source "$SCRIPT_DIR/00-helpers.sh"
|
|
|
|
print_header "Cleaning up RabbitMQ backup demo (namespace: $NAMESPACE)"
|
|
|
|
kubectl -n "$NAMESPACE" delete restorejob.backups.cozystack.io \
|
|
"$RESTOREJOB_TOCOPY_NAME" "$RESTOREJOB_INPLACE_NAME" --ignore-not-found
|
|
kubectl -n "$NAMESPACE" delete plan.backups.cozystack.io "$PLAN_NAME" --ignore-not-found
|
|
kubectl -n "$NAMESPACE" delete backupjob.backups.cozystack.io "$BACKUPJOB_NAME" --ignore-not-found
|
|
|
|
# Prune only the Backup artifacts belonging to this demo's applications.
|
|
for app in "$RABBITMQ_SRC_NAME" "$RABBITMQ_TARGET_NAME"; do
|
|
kubectl -n "$NAMESPACE" get backups.backups.cozystack.io \
|
|
-o jsonpath='{range .items[?(@.spec.applicationRef.name=="'"$app"'")]}{.metadata.name}{"\n"}{end}' 2>/dev/null \
|
|
| while read -r b; do
|
|
[[ -n "$b" ]] && kubectl -n "$NAMESPACE" delete backups.backups.cozystack.io "$b" --ignore-not-found
|
|
done
|
|
done
|
|
|
|
kubectl -n "$NAMESPACE" delete rabbitmq.apps.cozystack.io \
|
|
"$RABBITMQ_SRC_NAME" "$RABBITMQ_TARGET_NAME" --ignore-not-found
|
|
|
|
# The Backup deletions above run their S3 cleanup Job through the strategy and
|
|
# the creds/CA Secrets, so tear those down only now that the Backups are gone.
|
|
kubectl -n "$NAMESPACE" delete secret "$CREDS_SECRET" "$CA_SECRET" --ignore-not-found
|
|
kubectl -n "$NAMESPACE" delete bucket.apps.cozystack.io "$BUCKET_NAME" --ignore-not-found
|
|
kubectl delete backupclass.backups.cozystack.io "$BACKUPCLASS_NAME" --ignore-not-found
|
|
kubectl delete rabbitmqs.strategy.backups.cozystack.io "$STRATEGY_NAME" --ignore-not-found
|
|
|
|
log_success "cleanup complete"
|