Skip to content

Lessen severity of waiting loop errors to warnings #56

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jul 10, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions test/remote/remote/ssh.go
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,11 @@ func SSHNoSudo(host string, cmd ...string) (string, error) {
return runSSHCommand("ssh", append([]string{GetHostnameOrIP(host), "--"}, cmd...)...)
}

// SSHCheckAlive just pings the server quickly to check whether it is reachable by SSH
func SSHCheckAlive(host string) (string, error) {
return runSSHCommand("ssh", []string{GetHostnameOrIP(host), "-o", "ConnectTimeout=10", "--", "echo"}...)
}

// runSSHCommand executes the ssh or scp command, adding the flag provided --ssh-options
func runSSHCommand(cmd string, args ...string) (string, error) {
if pk, ok := os.LookupEnv("JENKINS_GCE_SSH_PRIVATE_KEY_FILE"); ok {
Expand Down
11 changes: 5 additions & 6 deletions test/remote/run_remote/run_remote.go
Original file line number Diff line number Diff line change
Expand Up @@ -394,18 +394,17 @@ func createInstance(serviceAccount string) (string, error) {
}

then := time.Now()
err = wait.Poll(10*time.Second, 5*time.Minute, func() (bool, error) {
err = wait.Poll(15*time.Second, 5*time.Minute, func() (bool, error) {
glog.V(2).Infof("Waiting for instance %v to come up. %v elapsed", name, time.Since(then))
var instance *compute.Instance
instance, err = computeService.Instances.Get(*project, *zone, name).Do()
if err != nil {
glog.Error(err)
glog.Errorf("Failed to get instance %v: %v", name, err)
return false, nil
}

if strings.ToUpper(instance.Status) != "RUNNING" {
err = fmt.Errorf("instance %s not in state RUNNING, was %s", name, instance.Status)
glog.Error(err)
glog.Warningf("instance %s not in state RUNNING, was %s", name, instance.Status)
return false, nil
}

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

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

Expand Down