summaryrefslogtreecommitdiff
path: root/jenkins-helpers.sh
diff options
context:
space:
mode:
authorChristophe Lyon <christophe.lyon@linaro.org>2020-08-03 06:59:42 +0000
committerChristophe Lyon <christophe.lyon@linaro.org>2020-08-12 09:34:50 +0000
commit9b14091d683d9cd46b939a64b74a649fe0e5522e (patch)
tree97d92265901add042b03bc64578af729e29a0d33 /jenkins-helpers.sh
parent3e4ee646d1d12b44a41e35747696559ec6f355c4 (diff)
jenkins-helpers.sh: Add "failsafe" parameter to print_host_for_node
When we call print_host_for_node from print_node_with_least_containers, we don't want to fail early with an error if any of the tester nodes is offline, so keep iterating until we find a suitable one. Change-Id: I0e6159a54f40ba83a56af03289ea905ed97cb7e9
Diffstat (limited to 'jenkins-helpers.sh')
-rw-r--r--jenkins-helpers.sh16
1 files changed, 9 insertions, 7 deletions
diff --git a/jenkins-helpers.sh b/jenkins-helpers.sh
index 389b7092..eef41fde 100644
--- a/jenkins-helpers.sh
+++ b/jenkins-helpers.sh
@@ -126,12 +126,14 @@ print_node_with_least_containers ()
testers=$(print_nodes_in_labels ${tester_labels[*]} | sort --random-sort)
for tester in $testers; do
ret=0
- tester_host=$(print_host_for_node $tester)
- load_value=$(timeout 30s ssh ${tester_host} docker ps | wc -l) || ret=$?
- if [ $ret -eq 0 ]; then
- if [ "$load_value" -lt "$tester_min_load_value" ]; then
- tester_min_load_name=$tester
- tester_min_load_value=$load_value
+ tester_host=$(print_host_for_node $tester "ignore_fail")
+ if [ x"${tester_host}" != x"" ]; then
+ load_value=$(timeout 30s ssh ${tester_host} docker ps | wc -l) || ret=$?
+ if [ $ret -eq 0 ]; then
+ if [ "$load_value" -lt "$tester_min_load_value" ]; then
+ tester_min_load_name=$tester
+ tester_min_load_value=$load_value
+ fi
fi
fi
done
@@ -188,7 +190,7 @@ print_host_for_node ()
host=""
done
- if [ x"$host" = x"" ]; then
+ if [ x"$host" = x"" ] && [ x"$2" != x"ignore_fail" ]; then
echo "Error: print_host_for_node() cannot ssh to $1 or $1.tcwglab" >&2
exit 1
fi