From 822c80dda61103ac2cfe019bbd9999d0fbfbdae2 Mon Sep 17 00:00:00 2001 From: Niklas Ye Date: Sat, 3 Oct 2026 18:15:42 +0200 Subject: [PATCH] examples/demo: split the Ready wait so escalation rules wait on alice too wait_for_ready waited for every demo object at once, including terdutescalationrule-platform, which names alice as a level-1 target -- but alice does not exist yet at that point in main(): she is created by redeem_platform_invite, which ran after wait_for_ready. terdut-server resolves every named username at reconcile time, not just when an escalation actually fires, so that CR could never reach Ready before alice did, and main() had no step in between to create her. Split into wait_for_objects (the shared loop, now taking its object list as arguments) plus two callers: wait_for_teams_ready, covering just the server and the two teams redeem_platform_invite/join_payments_team need, run before alice exists; wait_for_remaining_ready, covering the escalation rules, dead man's switches and alert sources, run after. Co-authored-by: Claude --- examples/demo/run-demo.sh | 44 ++++++++++++++++++++++++++------------- 1 file changed, 30 insertions(+), 14 deletions(-) diff --git a/examples/demo/run-demo.sh b/examples/demo/run-demo.sh index e589f13..013bf80 100755 --- a/examples/demo/run-demo.sh +++ b/examples/demo/run-demo.sh @@ -107,26 +107,41 @@ apply_demo() { kubectl apply -n "$NAMESPACE" -k "$SCRIPT_DIR" >/dev/null } -wait_for_ready() { - local objects=( - "terdutserver/terdut-operator-demo" - "terdutteam/terdutteam-platform" - "terdutteam/terdutteam-payments" - "terdutescalationrule/terdutescalationrule-platform" - "terdutescalationrule/terdutescalationrule-payments" - "terdutdeadmanswitch/terdutdeadmanswitch-platform" - "terdutdeadmanswitch/terdutdeadmanswitch-payments" - "terdutalertsource/terdutalertsource-platform" - "terdutalertsource/terdutalertsource-payments" - ) +wait_for_objects() { local obj - for obj in "${objects[@]}"; do + for obj in "$@"; do log "waiting for $obj to become Ready" kubectl wait --for=condition=Ready --timeout "$WAIT_TIMEOUT" -n "$NAMESPACE" "$obj" >/dev/null \ || die "timed out waiting for $obj -- try: kubectl describe -n $NAMESPACE $obj" done } +# Just the server and the two teams -- everything redeem_platform_invite and +# join_payments_team need. Deliberately NOT the escalation rules here: this +# demo kit's own terdutescalationrule-platform names alice as a level-1 +# target, and that CR cannot reach Ready until alice actually exists +# (terdut-server resolves every named username at reconcile time, not just +# at escalation time) -- a real dependency this script has to satisfy by +# creating her first, not something kubectl wait can be told to ignore. +wait_for_teams_ready() { + wait_for_objects \ + "terdutserver/terdut-operator-demo" \ + "terdutteam/terdutteam-platform" \ + "terdutteam/terdutteam-payments" +} + +# Everything that was waiting on alice (or just on the teams above, now +# already satisfied) to exist. +wait_for_remaining_ready() { + wait_for_objects \ + "terdutescalationrule/terdutescalationrule-platform" \ + "terdutescalationrule/terdutescalationrule-payments" \ + "terdutdeadmanswitch/terdutdeadmanswitch-platform" \ + "terdutdeadmanswitch/terdutdeadmanswitch-payments" \ + "terdutalertsource/terdutalertsource-platform" \ + "terdutalertsource/terdutalertsource-payments" +} + start_port_forward() { # A stale pidfile from an earlier run would otherwise collide with us on # $LOCAL_PORT -- if that pid is still alive, stop it first. @@ -319,10 +334,11 @@ main() { ensure_kind_cluster install_operator apply_demo - wait_for_ready + wait_for_teams_ready start_port_forward redeem_platform_invite join_payments_team + wait_for_remaining_ready fire_demo_alerts print_summary