Skip to content

Commit 25f0b91

Browse files
authored
fix(migrations): handle missing rabbitmq CRD in migration 34 (#2168)
## Summary - Migration 34 fails with `error: the server doesn't have a resource type "rabbitmqs"` when `rabbitmqs.apps.cozystack.io` CRD does not exist on the cluster - This happens when RabbitMQ was never installed — the CRD is not present, `kubectl get` fails, and `set -euo pipefail` terminates the migration job - Added a CRD existence check before listing resources; if CRD is absent, the migration stamps the version and exits cleanly ## Test plan - [ ] Deploy a cluster without RabbitMQ installed and run migration 34 — should skip gracefully - [ ] Deploy a cluster with RabbitMQ instances without `spec.version` set — should patch them to `v3.13` - [ ] Deploy a cluster with RabbitMQ instances already having `spec.version` — should skip patching
2 parents 5c7311d + 21f293a commit 25f0b91

1 file changed

Lines changed: 9 additions & 0 deletions

File tree

  • packages/core/platform/images/migrations/migrations

‎packages/core/platform/images/migrations/migrations/34‎

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,15 @@
1313
set -euo pipefail
1414

1515
DEFAULT_VERSION="v3.13"
16+
17+
# Skip if the CRD does not exist (rabbitmq was never installed)
18+
if ! kubectl api-resources --api-group=apps.cozystack.io -o name 2>/dev/null | grep -q '^rabbitmqs\.'; then
19+
echo "CRD rabbitmqs.apps.cozystack.io not found, skipping migration"
20+
kubectl create configmap -n cozy-system cozystack-version \
21+
--from-literal=version=35 --dry-run=client -o yaml | kubectl apply -f-
22+
exit 0
23+
fi
24+
1625
RABBITMQS=$(kubectl get rabbitmqs.apps.cozystack.io -A -o jsonpath='{range .items[*]}{.metadata.namespace}/{.metadata.name}{"\n"}{end}')
1726
for resource in $RABBITMQS; do
1827
NS="${resource%%/*}"

0 commit comments

Comments
 (0)