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