Skip to content

Commit 6dcdaaf

Browse files
authored
Merge pull request #56 from davidz627/fix/e2eError
Lessen severity of waiting loop errors to warnings
2 parents 80f6b7a + 91daa4b commit 6dcdaaf

File tree

2 files changed

+10
-6
lines changed

2 files changed

+10
-6
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

+5-6
Original file line numberDiff line numberDiff line change
@@ -394,18 +394,17 @@ 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()
401401
if err != nil {
402-
glog.Error(err)
402+
glog.Errorf("Failed to get instance %v: %v", name, err)
403403
return false, nil
404404
}
405405

406406
if strings.ToUpper(instance.Status) != "RUNNING" {
407-
err = fmt.Errorf("instance %s not in state RUNNING, was %s", name, instance.Status)
408-
glog.Error(err)
407+
glog.Warningf("instance %s not in state RUNNING, was %s", name, instance.Status)
409408
return false, nil
410409
}
411410

@@ -414,9 +413,9 @@ func createInstance(serviceAccount string) (string, error) {
414413
remote.AddHostnameIP(name, externalIP)
415414
}
416415

417-
if sshOut, err := remote.SSHNoSudo(name, "echo"); err != nil {
416+
if sshOut, err := remote.SSHCheckAlive(name); err != nil {
418417
err = fmt.Errorf("Instance %v in state RUNNING but not available by SSH: %v", name, err)
419-
glog.Errorf("SSH encountered an error: %v, output: %v", err, sshOut)
418+
glog.Warningf("SSH encountered an error: %v, output: %v", err, sshOut)
420419
return false, nil
421420
}
422421

0 commit comments

Comments
 (0)