summaryrefslogtreecommitdiff
path: root/jenkins-helpers.sh
diff options
context:
space:
mode:
authorMaxim Kuvyrkov <maxim.kuvyrkov@linaro.org>2020-04-24 14:34:19 +0000
committerMaxim Kuvyrkov <maxim.kuvyrkov@linaro.org>2020-04-27 17:25:29 +0000
commitb39cebb22cdd9a9220fb96069ed838e4c998fd16 (patch)
tree080afdcc5b17544bfbda79690f0ad8ce30ccfb9b /jenkins-helpers.sh
parent52eb5a521c093601e3fba856599288bad7a5d96f (diff)
jenkins-helpers.sh: Rework print_host_for_node to rely only on ssh
Which gives us control over TCWG "DNS" when combined with https://review.linaro.org/c/ci/dockerfiles/+/34893 . Change-Id: Ia9b483f195936fa27422ecaa24a9c3d16c1b446a
Diffstat (limited to 'jenkins-helpers.sh')
-rw-r--r--jenkins-helpers.sh31
1 files changed, 14 insertions, 17 deletions
diff --git a/jenkins-helpers.sh b/jenkins-helpers.sh
index f274e890..4e0ad8ff 100644
--- a/jenkins-helpers.sh
+++ b/jenkins-helpers.sh
@@ -160,30 +160,27 @@ print_hw_id_for_node ()
}
# $1: Jenkins $NODE_NAME
-# Prints DNS hostname
+# Prints SSH host
print_host_for_node ()
{
(
set -euf -o pipefail
- # We first check if $1 is known by the DNS inside .tcwglab. If
- # not, it might be an external machine for which we have
- # configured ssh
- local host="$1.tcwglab"
-
- # Map tcwg-x86_64-build-* and tcwg-x86_64-dev-* to build-* and dev-*
- case "$host" in
- tcwg-x86_64-*) host=${host#tcwg-x86_64-} ;;
- esac
+ local host
- if ! host "$host" >& /dev/null; then
- # No DNS entry, try to see if it is handled by our ssh config
- if ! ssh "$1" true >& /dev/null; then
- echo "Error: no DNS entry and no SSH configuration for $host" >&2
- exit 1
- else
- host="$1"
+ # All jenkins nodes have either <NODE> or <NODE>.tcwglab entry in
+ # .ssh/config (in dockerfiles.git/tcwg-base/tcwg-buildslave/).
+ for suffix in "" ".tcwglab"; do
+ host="$1$suffix"
+ if timeout 30s ssh "$host" true >& /dev/null; then
+ break
fi
+ host=""
+ done
+
+ if [ x"$host" = x"" ]; then
+ echo "Error: print_host_for_node() cannot ssh to $1 or $1.tcwglab" >&2
+ exit 1
fi
echo "$host"