Skip to content

Commit 289ae6c

Browse files
authored
Merge pull request #2184 from mattcary/e2e-wg
Move wg.Add outside of gofunc in setup_e2e_test
2 parents 7568643 + a931f88 commit 289ae6c

File tree

3 files changed

+13
-5
lines changed

3 files changed

+13
-5
lines changed

test/e2e/tests/setup_e2e_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,8 +120,8 @@ var _ = BeforeSuite(func() {
120120
tcc <- NewDefaultTestContext(curZone, strconv.Itoa(randInt))
121121
}(zone, j)
122122
}
123+
wg.Add(1)
123124
go func(curZone string) {
124-
wg.Add(1)
125125
defer GinkgoRecover()
126126
defer wg.Done()
127127
hdtcc <- NewTestContext(curZone, *hdMinCpuPlatform, *hdMachineType, "0")

test/remote/instance.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -248,9 +248,9 @@ func (i *InstanceInfo) CreateOrGetInstance(localSSDCount int) error {
248248
i.externalIP = externalIP
249249
}
250250

251-
if sshOut, err := i.SSHCheckAlive(); err != nil {
251+
if err := i.SSHCheckAlive(); err != nil {
252252
err = fmt.Errorf("Instance %v in state RUNNING but not available by SSH: %v", i.cfg.Name, err.Error())
253-
klog.Warningf("SSH encountered an error: %v, output: %v", err, sshOut)
253+
klog.Warningf("SSH encountered an error: %v", err)
254254
return false, nil
255255
}
256256
klog.V(4).Infof("Instance %v in state RUNNING and available by SSH", i.cfg.Name)

test/remote/ssh.go

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,9 @@ import (
2222
"os/exec"
2323
"os/user"
2424
"strings"
25+
"time"
2526

27+
"k8s.io/apimachinery/pkg/util/wait"
2628
"k8s.io/klog/v2"
2729
)
2830

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

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

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

0 commit comments

Comments
 (0)