Skip to content

Commit

Permalink
Work around concurrent |gcloud compute ssh| terminal issue
Browse files Browse the repository at this point in the history
  • Loading branch information
mvines committed Sep 5, 2018
1 parent e677cda commit 89db85d
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
4 changes: 2 additions & 2 deletions net/gce.sh
Original file line number Diff line number Diff line change
Expand Up @@ -158,10 +158,10 @@ EOF
echo "clientIpList=()" >> "$configFile"
echo "Looking for client instances..."
gcloud_FindInstances "name~^$prefix-client" show
if [[ ${#instances[@]} -gt 0 ]]; then
[[ ${#instances[@]} -eq 0 ]] || {
gcloud_PrepInstancesForSsh "$gcloud_username" "$sshPrivateKey"
gcloud_ForEachInstance recordInstanceIp clientIpList
fi
}

echo "Wrote $configFile"
}
Expand Down
9 changes: 8 additions & 1 deletion scripts/gcloud.sh
Original file line number Diff line number Diff line change
Expand Up @@ -241,6 +241,10 @@ gcloud_PrepInstancesForSsh() {
IFS=: read -r name zone publicIp _ < <(echo "$instanceInfo")

logFile="$logDir/gcloud_PrepInstancesForSsh-$name.log"

# TODO: This next subshell runs in series because for unknown reason running
# multiple |gcloud compute ssh| commands in parallel cause the macOS
# terminal to misbehave
(
set -x

Expand All @@ -260,12 +264,15 @@ gcloud_PrepInstancesForSsh() {
StrictHostKeyChecking no
\" > .ssh/config;
"
) >> "$logFile" 2>&1
(
set -x
scp \
-o StrictHostKeyChecking=no \
-o UserKnownHostsFile=/dev/null \
-i "$privateKey" \
"$privateKey" "$username@$publicIp:.ssh/id_testnet"
) > "$logFile" 2>&1 &
) >> "$logFile" 2>&1 &
declare pid=$!

ln -sfT "$logFile" "$logDir/gcloud_PrepInstancesForSsh-$pid.log"
Expand Down

0 comments on commit 89db85d

Please sign in to comment.