Skip to content

Commit bada0f9

Browse files
author
Tom Barnes
committed
release lease if LEASE_ID set and cleanup.sh fails
1 parent 4ac5bc5 commit bada0f9

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

src/integration-tests/bash/cleanup.sh

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,9 @@
1616
# PV_ROOT The root directory on the kubernetes cluster
1717
# used for persistent volumes.
1818
#
19+
# LEASE_ID Set this if you want cleanup to release the
20+
# given lease on a failure.
21+
#
1922
# See 'run.sh' for a detailed description of RESULT_ROOT and PV_ROOT.
2023
#
2124
# --------------------
@@ -40,6 +43,9 @@
4043
#
4144
# Phase 4: Delete the local test output directory.
4245
#
46+
# Phase 5: If we own a lease, then release it on a failure
47+
# see LEASE_ID above.
48+
#
4349

4450
DOMAINS=(domain1 domain2 domain3 domain4 domain5)
4551
DOMAIN_NAMESPACES=(default default test1 test2 default)
@@ -334,6 +340,18 @@ rm -f /tmp/test_suite.*
334340

335341
# Bye
336342

343+
if [ ! "$LEASE_ID" = "" ] && [ ! "$SUCCESS" = "0" ]; then
344+
# release the lease if we own it
345+
${SCRIPTPATH}/lease.sh -d "$LEASE_ID" > /tmp/release_lease.out 2>&1
346+
if [ "$?" = "0" ]; then
347+
echo @@ Lease released.
348+
else
349+
echo @@ Lease could not be released:
350+
cat /tmp/release_lease.out
351+
fi
352+
rm -f /tmp/release_lease.out
353+
fi
354+
337355
echo @@ Exiting with status $SUCCESS
338356
exit $SUCCESS
339357

0 commit comments

Comments
 (0)