aboutsummaryrefslogtreecommitdiffstats
path: root/resources/libraries/bash/function/common.sh
diff options
context:
space:
mode:
Diffstat (limited to 'resources/libraries/bash/function/common.sh')
-rw-r--r--resources/libraries/bash/function/common.sh22
1 files changed, 18 insertions, 4 deletions
diff --git a/resources/libraries/bash/function/common.sh b/resources/libraries/bash/function/common.sh
index 8b83ab4e7e..69c70935c7 100644
--- a/resources/libraries/bash/function/common.sh
+++ b/resources/libraries/bash/function/common.sh
@@ -82,6 +82,20 @@ function check_download_dir () {
}
+function cleanup_topo () {
+
+ set -exuo pipefail
+
+ # Variables read:
+ # - WORKING_TOPOLOGY - Path to topology yaml file of the reserved testbed.
+ # - PYTHON_SCRIPTS_DIR - Path to directory holding the reservation script.
+
+ python "${PYTHON_SCRIPTS_DIR}/topo_cleanup.py" -t "${WORKING_TOPOLOGY}"
+ # Not using "|| die" as some callers might want to ignore errors,
+ # e.g. in teardowns, such as unreserve.
+}
+
+
function common_dirs () {
set -exuo pipefail
@@ -178,7 +192,7 @@ function copy_archives () {
# automatically archived to logs.fd.io.
if [[ -n "${WORKSPACE-}" ]]; then
mkdir -p "${WORKSPACE}/archives/" || die "Archives dir create failed."
- cp -r "${ARCHIVE_DIR}"/* "${WORKSPACE}/archives" || die "Copy failed."
+ cp -rf "${ARCHIVE_DIR}"/* "${WORKSPACE}/archives" || die "Copy failed."
fi
}
@@ -310,7 +324,7 @@ function reserve_testbed () {
}
die "Trap attempt failed, unreserve succeeded. Aborting."
}
- python "${PYTHON_SCRIPTS_DIR}/topo_cleanup.py" -t "${topo}" || {
+ cleanup_topo || {
die "Testbed cleanup failed."
}
break
@@ -630,9 +644,9 @@ function untrap_and_unreserve_testbed () {
wt="${WORKING_TOPOLOGY}" # Just to avoid too long lines.
if [[ -z "${wt-}" ]]; then
set -eu
- echo "Testbed looks unreserved already. Trap removal failed before?"
+ warn "Testbed looks unreserved already. Trap removal failed before?"
else
- python "${PYTHON_SCRIPTS_DIR}/topo_cleanup.py" -t "${wt}" || true
+ cleanup_topo || true
python "${PYTHON_SCRIPTS_DIR}/topo_reservation.py" -c -t "${wt}" || {
die "${1:-FAILED TO UNRESERVE, FIX MANUALLY.}" 2
}