Skip to content

Commit 91daa4b

Browse files
committed
Decreased SSH connection timeout time for health check
1 parent b09444a commit 91daa4b

File tree

2 files changed

+7
-2
lines changed

2 files changed

+7
-2
lines changed

test/remote/remote/ssh.go

+5
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,11 @@ func SSHNoSudo(host string, cmd ...string) (string, error) {
9393
return runSSHCommand("ssh", append([]string{GetHostnameOrIP(host), "--"}, cmd...)...)
9494
}
9595

96+
// SSHCheckAlive just pings the server quickly to check whether it is reachable by SSH
97+
func SSHCheckAlive(host string) (string, error) {
98+
return runSSHCommand("ssh", []string{GetHostnameOrIP(host), "-o", "ConnectTimeout=10", "--", "echo"}...)
99+
}
100+
96101
// runSSHCommand executes the ssh or scp command, adding the flag provided --ssh-options
97102
func runSSHCommand(cmd string, args ...string) (string, error) {
98103
if pk, ok := os.LookupEnv("JENKINS_GCE_SSH_PRIVATE_KEY_FILE"); ok {

test/remote/run_remote/run_remote.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -394,7 +394,7 @@ func createInstance(serviceAccount string) (string, error) {
394394
}
395395

396396
then := time.Now()
397-
err = wait.Poll(10*time.Second, 5*time.Minute, func() (bool, error) {
397+
err = wait.Poll(15*time.Second, 5*time.Minute, func() (bool, error) {
398398
glog.V(2).Infof("Waiting for instance %v to come up. %v elapsed", name, time.Since(then))
399399
var instance *compute.Instance
400400
instance, err = computeService.Instances.Get(*project, *zone, name).Do()
@@ -413,7 +413,7 @@ func createInstance(serviceAccount string) (string, error) {
413413
remote.AddHostnameIP(name, externalIP)
414414
}
415415

416-
if sshOut, err := remote.SSHNoSudo(name, "echo"); err != nil {
416+
if sshOut, err := remote.SSHCheckAlive(name); err != nil {
417417
err = fmt.Errorf("Instance %v in state RUNNING but not available by SSH: %v", name, err)
418418
glog.Warningf("SSH encountered an error: %v, output: %v", err, sshOut)
419419
return false, nil

0 commit comments

Comments
 (0)