Skip to content
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
2 changes: 1 addition & 1 deletion test/e2e/tests/setup_e2e_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -120,8 +120,8 @@ var _ = BeforeSuite(func() {
tcc <- NewDefaultTestContext(curZone, strconv.Itoa(randInt))
}(zone, j)
}
wg.Add(1)
go func(curZone string) {
wg.Add(1)
defer GinkgoRecover()
defer wg.Done()
hdtcc <- NewTestContext(curZone, *hdMinCpuPlatform, *hdMachineType, "0")
Expand Down
4 changes: 2 additions & 2 deletions test/remote/instance.go
Original file line number Diff line number Diff line change
Expand Up @@ -248,9 +248,9 @@ func (i *InstanceInfo) CreateOrGetInstance(localSSDCount int) error {
i.externalIP = externalIP
}

if sshOut, err := i.SSHCheckAlive(); err != nil {
if err := i.SSHCheckAlive(); err != nil {
err = fmt.Errorf("Instance %v in state RUNNING but not available by SSH: %v", i.cfg.Name, err.Error())
klog.Warningf("SSH encountered an error: %v, output: %v", err, sshOut)
klog.Warningf("SSH encountered an error: %v", err)
return false, nil
}
klog.V(4).Infof("Instance %v in state RUNNING and available by SSH", i.cfg.Name)
Expand Down
12 changes: 10 additions & 2 deletions test/remote/ssh.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,9 @@ import (
"os/exec"
"os/user"
"strings"
"time"

"k8s.io/apimachinery/pkg/util/wait"
"k8s.io/klog/v2"
)

Expand Down Expand Up @@ -88,8 +90,14 @@ func (i *InstanceInfo) SSHNoSudo(cmd ...string) (string, error) {
}

// SSHCheckAlive just pings the server quickly to check whether it is reachable by SSH
func (i *InstanceInfo) SSHCheckAlive() (string, error) {
return runSSHCommand("ssh", []string{i.GetSSHTarget(), "-o", "ConnectTimeout=10", "--", "echo"}...)
func (i *InstanceInfo) SSHCheckAlive() error {
return wait.Poll(5*time.Second, time.Minute, func() (bool, error) {
out, err := runSSHCommand("ssh", []string{i.GetSSHTarget(), "-o", "ConnectTimeout=10", "--", "echo"}...)
if err != nil {
klog.V(2).Infof("ssh error, retrying: %v, %s", err, out)
}
return err == nil, nil
})
}

// runSSHCommand executes the ssh or scp command, adding the flag provided --ssh-options
Expand Down