Skip to content

Commit 7b94287

Browse files
committed
fix(backups): wait for the platform strategy in rabbitmq and kafka demos
The rabbitmq and kafka-metadata backup demos read the platform's cozy-default-<engine> strategy once, right after install, where the Helm upgrade that renders it is gated on dependsOn and can leave it absent for minutes; the demo then failed immediately instead of waiting. Replace the single read with kubectl wait --for=create, so it polls through NotFound and fails only on a real error. Assisted-by: LLM Signed-off-by: IvanHunters <[email protected]>
1 parent 9e3ed1f commit 7b94287

2 files changed

Lines changed: 25 additions & 2 deletions

File tree

‎examples/backups/kafka-metadata/run-all.sh‎

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,19 @@ wait_hr_ready "kafka-${KAFKA_SRC_NAME}" 300
3737
kafka_wait_ready "$KAFKA_SRC_NAME" 600
3838

3939
print_header "Step 05a: Derive the demo Kafka strategy '${STRATEGY_NAME}' + BackupClass '${BACKUPCLASS_NAME}'"
40+
# Wait for the strategy rather than read it once. The shipped cozy-default-kafka
41+
# is rendered behind a lookup of the platform bucket, so it exists only once a
42+
# Helm upgrade has run after that bucket was provisioned. The controller forces
43+
# that upgrade, but helm-controller holds it while any release in its dependsOn
44+
# is not Ready, so a platform change made just before this runs can keep it
45+
# absent for minutes. Both the endpoint read below and provision_demo_strategy
46+
# derive from it, so wait once here; kubectl wait keeps polling through NotFound
47+
# and fails on any other error.
48+
log_substep "Waiting for the platform's cozy-default-kafka strategy..."
49+
kubectl wait --for=create kafka.strategy.backups.cozystack.io/cozy-default-kafka \
50+
--timeout=15m >/dev/null \
51+
|| { log_error "cozy-default-kafka strategy did not appear: enable the platform default backups (backupstrategy-controller) before running this demo"; exit 1; }
52+
4053
# The shipped cozy-default-kafka advertises the platform's EXTERNAL S3 ingress,
4154
# which in-cluster Pods cannot resolve or TLS-validate in CI. Derive a demo
4255
# strategy from it (so the driver script stays a single source of truth) pointed

‎examples/backups/rabbitmq/run-all.sh‎

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -120,9 +120,19 @@ print_header "Step 02: Create the Rabbitmq strategy + BackupClass"
120120
# Pod needs no package install at run time. Its presence also confirms the
121121
# platform default backups stack (backupstrategy-controller + CRDs) is installed,
122122
# without which the BackupJob below cannot reconcile at all.
123+
# Wait for it rather than read it once. The strategy is rendered behind a lookup
124+
# of the platform bucket, so it exists only once a Helm upgrade has run after
125+
# that bucket was provisioned. The controller forces that upgrade, but helm-
126+
# controller holds it while any release in its dependsOn is not Ready, so a
127+
# platform change made just before this runs can keep it absent for minutes.
128+
# kubectl wait keeps polling through NotFound and fails on any other error.
129+
log_substep "Waiting for the platform's cozy-default-rabbitmq strategy..."
130+
kubectl wait --for=create rabbitmqs.strategy.backups.cozystack.io/cozy-default-rabbitmq \
131+
--timeout=15m >/dev/null \
132+
|| { log_error "cozy-default-rabbitmq strategy did not appear: enable the platform default backups (backupstrategy-controller) before running this demo"; exit 1; }
123133
CLIENT_IMAGE=$(kubectl get rabbitmqs.strategy.backups.cozystack.io cozy-default-rabbitmq \
124-
-o jsonpath='{.spec.template.spec.containers[?(@.name=="rabbitmq-backup")].image}' 2>/dev/null || true)
125-
[[ -n "$CLIENT_IMAGE" ]] || { log_error "cozy-default-rabbitmq strategy not found: enable the platform default backups (backupstrategy-controller) before running this demo"; exit 1; }
134+
-o jsonpath='{.spec.template.spec.containers[?(@.name=="rabbitmq-backup")].image}')
135+
[[ -n "$CLIENT_IMAGE" ]] || { log_error "cozy-default-rabbitmq strategy has no rabbitmq-backup container image"; exit 1; }
126136
log_substep "Reusing the platform strategy's client image: ${CLIENT_IMAGE}"
127137
subst 03-rabbitmq-strategy.yaml | kubectl apply -f -
128138
kubectl apply -f "$SCRIPT_DIR/04-backupclass.yaml"

0 commit comments

Comments
 (0)