Skip to content

Commit 7c88a1f

Browse files
committed
workbench: only start the ssh servers when fetching the logs
1 parent 727482e commit 7c88a1f

File tree

1 file changed

+34
-23
lines changed

1 file changed

+34
-23
lines changed

nix/workbench/backend/nomad/cloud.sh

Lines changed: 34 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -106,28 +106,6 @@ backend_nomadcloud() {
106106

107107
start-cluster )
108108
backend_nomad start-cluster "$@"
109-
# start-ssh
110-
# Only if running on "perf" exclusive nodes we use SSH, if not
111-
# `nomad exec`, because we need to have an exclusive port open for us.
112-
if echo "${WB_SHELL_PROFILE}" | grep --quiet "cw-perf"
113-
then
114-
local jobs_array=()
115-
local nodes=($(jq_tolist keys "${dir}"/node-specs.json))
116-
for node in ${nodes[*]}
117-
do
118-
# TODO: Do it in parallel ?
119-
backend_nomad task-program-start "${dir}" "${node}" ssh &
120-
jobs_array+=("$!")
121-
done
122-
# Wait and check!
123-
if test -n "${jobs_array}"
124-
then
125-
if ! wait_fail_any "${jobs_array[@]}"
126-
then
127-
fatal "Failed to start ssh server(s)"
128-
fi
129-
fi
130-
fi
131109
;;
132110

133111
start-tracers )
@@ -824,6 +802,39 @@ fetch-logs-nomadcloud() {
824802
local dir=${1:?$usage}; shift
825803

826804
msg "Fetch logs ..."
805+
806+
msg "First start the sandboxed SSH servers ..."
807+
# Only if running on "perf" exclusive nodes we use SSH, if not
808+
# `nomad exec`, because we need to have an exclusive port open for us.
809+
if echo "${WB_SHELL_PROFILE}" | grep --quiet "cw-perf"
810+
then
811+
local jobs_array=()
812+
local nodes=($(jq_tolist keys "${dir}"/node-specs.json))
813+
for node in ${nodes[*]}
814+
do
815+
# TODO: Do it in parallel ?
816+
backend_nomad task-program-start "${dir}" "${node}" ssh &
817+
jobs_array+=("$!")
818+
done
819+
# Wait and check!
820+
if test -n "${jobs_array}"
821+
then
822+
if ! wait_fail_any "${jobs_array[@]}"
823+
then
824+
fatal "Failed to start ssh server(s)"
825+
fi
826+
fi
827+
fi
828+
829+
fetch-logs-nomadcloud-retry "${dir}"
830+
831+
msg "Sandboxed SSH servers will be kept running for debugging purposes"
832+
}
833+
834+
fetch-logs-nomadcloud-retry() {
835+
local usage="USAGE: wb backend $op RUN-DIR"
836+
local dir=${1:?$usage}; shift
837+
827838
local jobs_array=()
828839
for node in $(jq_tolist 'keys' "${dir}"/node-specs.json)
829840
do
@@ -844,7 +855,7 @@ fetch-logs-nomadcloud() {
844855
msg "$(red "Failed to fetch some logs")"
845856
msg "Check files \"${dir}/nomad/NODE/download_ok\" and \"${dir}/nomad/NODE/download_failed\""
846857
read -p "Hit enter to retry ..."
847-
fetch-logs-nomadcloud "${dir}"
858+
fetch-logs-nomadcloud-retry "${dir}"
848859
else
849860
msg "$(green "Finished fetching logs")"
850861
fi

0 commit comments

Comments
 (0)