diff --git a/hack/install-ate.sh b/hack/install-ate.sh index 5ace949c2b..14b7f2c849 100755 --- a/hack/install-ate.sh +++ b/hack/install-ate.sh @@ -38,6 +38,11 @@ fi # ATE_DEMOS is an array that registers the prefix name of the demo functions. ATE_DEMOS=() +# Called by a ${demo}_cmdline handler for an argument it does not own. +ate_demo_flag_unhandled() { + ATE_DEMO_FLAG_HANDLED=false +} + # Include demos. source "${ROOT}"/hack/install-demo-counter.sh source "${ROOT}"/hack/install-demo-egress.sh @@ -627,7 +632,7 @@ get_actor_status() { } # prepare_actor_for_delete suspends (or resumes then suspends) until DeleteActor -# is allowed. Actors must be STATUS_SUSPENDED before deletion. +# accepts the actor: STATUS_SUSPENDED, STATUS_CRASHED, or STATUS_DELETING. prepare_actor_for_delete() { local actor_name="$1" local atespace="$2" @@ -641,7 +646,7 @@ prepare_actor_for_delete() { fi case "${status}" in - STATUS_SUSPENDED) + STATUS_SUSPENDED | STATUS_CRASHED | STATUS_DELETING) return 0 ;; STATUS_PAUSED) @@ -660,7 +665,7 @@ prepare_actor_for_delete() { sleep 2 done - echo "timed out waiting for actor ${actor_name} to reach STATUS_SUSPENDED" >&2 + echo "timed out waiting for actor ${actor_name} to become deletable" >&2 return 1 } @@ -849,17 +854,21 @@ esac store_backend >/dev/null while [[ "$#" -gt 0 ]]; do - # Run ${demo}_cmdline if it exists. If it returns 0, then we successfully - # handled this argument and can continue. Otherwise, fallthrough to check - # the other arguments. + # Handlers signal an unclaimed argument via ate_demo_flag_unhandled, not exit + # status: an `if`-condition call would suppress errexit in the whole call tree. + ATE_DEMO_FLAG_HANDLED=false for demo_name in "${ATE_DEMOS[@]}"; do - if declare -F "${demo_name}_cmdline" >/dev/null 2>&1; then - if "${demo_name}_cmdline" "$1"; then - shift - continue 2 - fi + declare -F "${demo_name}_cmdline" >/dev/null 2>&1 || continue + ATE_DEMO_FLAG_HANDLED=true + "${demo_name}_cmdline" "$1" + if [[ "${ATE_DEMO_FLAG_HANDLED}" == "true" ]]; then + break fi done + if [[ "${ATE_DEMO_FLAG_HANDLED}" == "true" ]]; then + shift + continue + fi case $1 in --ateapi-client-auth=*) ATE_ATEAPI_CLIENT_AUTH="${1#*=}" ;; diff --git a/hack/install-demo-autoscaled-workerpool.sh b/hack/install-demo-autoscaled-workerpool.sh index adb2abf67a..26b16e6f0b 100644 --- a/hack/install-demo-autoscaled-workerpool.sh +++ b/hack/install-demo-autoscaled-workerpool.sh @@ -27,10 +27,9 @@ demo-autoscaled-workerpool_cmdline() { --deploy-demo-autoscaled-workerpool) demo-autoscaled-workerpool_deploy ;; --delete-demo-autoscaled-workerpool) demo-autoscaled-workerpool_delete ;; *) - return 1 + ate_demo_flag_unhandled ;; esac - return 0 } demo-autoscaled-workerpool_deploy() { diff --git a/hack/install-demo-claude-code-multiplex.sh b/hack/install-demo-claude-code-multiplex.sh index 5a5e3b9778..1e1d2d07b1 100644 --- a/hack/install-demo-claude-code-multiplex.sh +++ b/hack/install-demo-claude-code-multiplex.sh @@ -23,10 +23,9 @@ demo-claude-code-multiplex_cmdline() { --deploy-demo-claude-code-multiplex) demo-claude-code-multiplex_deploy ;; --delete-demo-claude-code-multiplex) demo-claude-code-multiplex_delete ;; *) - return 1 + ate_demo_flag_unhandled ;; esac - return 0 } # Build the workload image, push to ${KO_DOCKER_REPO}, and echo the resolved diff --git a/hack/install-demo-counter.sh b/hack/install-demo-counter.sh index c2248271e3..7a25bdb668 100644 --- a/hack/install-demo-counter.sh +++ b/hack/install-demo-counter.sh @@ -28,10 +28,9 @@ demo-counter_cmdline() { --deploy-demo-counter-with-external-volume) demo-counter_deploy "true" ;; --delete-demo-counter) demo-counter_delete ;; *) - return 1 + ate_demo_flag_unhandled ;; esac - return 0 } demo-counter_deploy() { diff --git a/hack/install-demo-egress.sh b/hack/install-demo-egress.sh index e4e0074a9d..3140430510 100644 --- a/hack/install-demo-egress.sh +++ b/hack/install-demo-egress.sh @@ -23,10 +23,9 @@ demo-egress_cmdline() { --deploy-demo-egress) demo-egress_deploy ;; --delete-demo-egress) demo-egress_delete ;; *) - return 1 + ate_demo_flag_unhandled ;; esac - return 0 } demo-egress_deploy() { diff --git a/hack/install-demo-multi-template.sh b/hack/install-demo-multi-template.sh index 0d05582846..2b123170af 100644 --- a/hack/install-demo-multi-template.sh +++ b/hack/install-demo-multi-template.sh @@ -23,10 +23,9 @@ demo-multi-template_cmdline() { --deploy-demo-multi-template) demo-multi-template_deploy ;; --delete-demo-multi-template) demo-multi-template_delete ;; *) - return 1 + ate_demo_flag_unhandled ;; esac - return 0 } demo-multi-template_deploy() { diff --git a/hack/install-demo-parking.sh b/hack/install-demo-parking.sh index 72d72e826c..1af3751408 100644 --- a/hack/install-demo-parking.sh +++ b/hack/install-demo-parking.sh @@ -23,10 +23,9 @@ demo-parking_cmdline() { --deploy-demo-parking) demo-parking_deploy ;; --delete-demo-parking) demo-parking_delete ;; *) - return 1 + ate_demo_flag_unhandled ;; esac - return 0 } demo-parking_deploy() { diff --git a/hack/install-demo-sandbox.sh b/hack/install-demo-sandbox.sh index fb32097498..589a9f339b 100644 --- a/hack/install-demo-sandbox.sh +++ b/hack/install-demo-sandbox.sh @@ -23,10 +23,9 @@ demo-sandbox_cmdline() { --deploy-demo-sandbox) demo-sandbox_deploy ;; --delete-demo-sandbox) demo-sandbox_delete ;; *) - return 1 + ate_demo_flag_unhandled ;; esac - return 0 } demo-sandbox_deploy() {