From e660adbad83e3a793f6cae628402f7ada817c016 Mon Sep 17 00:00:00 2001 From: Joe Finney Date: Mon, 7 Mar 2016 13:29:04 -0800 Subject: [PATCH] Add connect timeout to ssh-to-node. --- cluster/aws/util.sh | 4 +++- cluster/gce/util.sh | 4 ++-- cluster/gke/util.sh | 4 ++-- cluster/libvirt-coreos/util.sh | 2 +- 4 files changed, 8 insertions(+), 6 deletions(-) diff --git a/cluster/aws/util.sh b/cluster/aws/util.sh index 96882dbd59c..13639fa56fb 100755 --- a/cluster/aws/util.sh +++ b/cluster/aws/util.sh @@ -1511,10 +1511,12 @@ function ssh-to-node { fi for try in $(seq 1 5); do - if ssh -oLogLevel=quiet -oStrictHostKeyChecking=no -i "${AWS_SSH_KEY}" ${SSH_USER}@${ip} "${cmd}"; then + if ssh -oLogLevel=quiet -oConnectTimeout=30 -oStrictHostKeyChecking=no -i "${AWS_SSH_KEY}" ${SSH_USER}@${ip} "echo test > /dev/null"; then break fi + sleep 5 done + ssh -oLogLevel=quiet -oConnectTimeout=30 -oStrictHostKeyChecking=no -i "${AWS_SSH_KEY}" ${SSH_USER}@${ip} "${cmd}" } # Restart the kube-proxy on a node ($1) diff --git a/cluster/gce/util.sh b/cluster/gce/util.sh index 724834d9d03..78c8a7aba55 100755 --- a/cluster/gce/util.sh +++ b/cluster/gce/util.sh @@ -1319,13 +1319,13 @@ function ssh-to-node { local cmd="$2" # Loop until we can successfully ssh into the box for try in $(seq 1 5); do - if gcloud compute ssh --ssh-flag="-o LogLevel=quiet" --project "${PROJECT}" --zone="${ZONE}" "${node}" --command "echo test > /dev/null"; then + if gcloud compute ssh --ssh-flag="-o LogLevel=quiet" --ssh-flag="-o ConnectTimeout=30" --project "${PROJECT}" --zone="${ZONE}" "${node}" --command "echo test > /dev/null"; then break fi sleep 5 done # Then actually try the command. - gcloud compute ssh --ssh-flag="-o LogLevel=quiet" --project "${PROJECT}" --zone="${ZONE}" "${node}" --command "${cmd}" + gcloud compute ssh --ssh-flag="-o LogLevel=quiet" --ssh-flag="-o ConnectTimeout=30" --project "${PROJECT}" --zone="${ZONE}" "${node}" --command "${cmd}" } # Restart the kube-proxy on a node ($1) diff --git a/cluster/gke/util.sh b/cluster/gke/util.sh index cc1931bffb7..e2a6e112965 100755 --- a/cluster/gke/util.sh +++ b/cluster/gke/util.sh @@ -263,13 +263,13 @@ function ssh-to-node() { local cmd="$2" # Loop until we can successfully ssh into the box for try in $(seq 1 5); do - if gcloud compute ssh --ssh-flag="-o LogLevel=quiet" --project "${PROJECT}" --zone="${ZONE}" "${node}" --command "echo test > /dev/null"; then + if gcloud compute ssh --ssh-flag="-o LogLevel=quiet" --ssh-flag="-o ConnectTimeout=30" --project "${PROJECT}" --zone="${ZONE}" "${node}" --command "echo test > /dev/null"; then break fi sleep 5 done # Then actually try the command. - gcloud compute ssh --ssh-flag="-o LogLevel=quiet" --project "${PROJECT}" --zone="${ZONE}" "${node}" --command "${cmd}" + gcloud compute ssh --ssh-flag="-o LogLevel=quiet" --ssh-flag="-o ConnectTimeout=30" --project "${PROJECT}" --zone="${ZONE}" "${node}" --command "${cmd}" } # Restart the kube-proxy on a node ($1) diff --git a/cluster/libvirt-coreos/util.sh b/cluster/libvirt-coreos/util.sh index f70d202e769..f10ccfddb90 100644 --- a/cluster/libvirt-coreos/util.sh +++ b/cluster/libvirt-coreos/util.sh @@ -345,7 +345,7 @@ function ssh-to-node { if [[ -z "$machine" ]]; then echo "$node is an unknown machine to ssh to" >&2 fi - ssh -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null -o ControlMaster=no "core@$machine" "$cmd" + ssh -o ConnectTimeout=30 -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null -o ControlMaster=no "core@$machine" "$cmd" } # Restart the kube-proxy on a node ($1)