From bc4fd4955a2da719d4c3f7676d2dae6173e63b03 Mon Sep 17 00:00:00 2001 From: Brandon Squizzato Date: Thu, 20 Jan 2022 14:40:44 -0500 Subject: [PATCH] Fix ns teardown when standard deploy scripts were not used --- cicd/_common_deploy_logic.sh | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/cicd/_common_deploy_logic.sh b/cicd/_common_deploy_logic.sh index 6816e07c..c116eff4 100644 --- a/cicd/_common_deploy_logic.sh +++ b/cicd/_common_deploy_logic.sh @@ -60,8 +60,13 @@ function teardown { echo "----- TEARING DOWN -----" echo "------------------------" local ns - RESERVED_NAMESPACES="$DB_NAMESPACE $SMOKE_NAMESPACE" - for ns in $RESERVED_NAMESPACES; do + + # run teardown on all namespaces possibly reserved in this run + RESERVED_NAMESPACES=("${NAMESPACE}" "${DB_NAMESPACE}" "${SMOKE_NAMESPACE}") + # remove duplicates (https://stackoverflow.com/a/13648438) + UNIQUE_NAMESPACES=($(echo "${RESERVED_NAMESPACES[@]}" | tr ' ' '\n' | sort -u | tr '\n' ' ')) + + for ns in ${UNIQUE_NAMESPACES[@]}; do echo "Running teardown for ns: $ns" set +e collect_k8s_artifacts $ns