aboutsummaryrefslogtreecommitdiffstats
path: root/vm
diff options
context:
space:
mode:
authorDmitry Vyukov <dvyukov@google.com>2017-11-20 11:57:42 +0100
committerDmitry Vyukov <dvyukov@google.com>2017-11-20 11:57:42 +0100
commit2d24bbb2259bd5064ccbea7a46c30591660b1a97 (patch)
tree4adec2ae5c40cc999307282c49075d0d6d5e7660 /vm
parent9badd05327bc3a1a96c828de3c32dc8101be77cc (diff)
vm/gce: fix nil deref
New console output code crashes with nil deref, because we shadow outer err variable and then dereference nil err. Also express ssh connect timeout in real time. Currently the timeout is on par of ~25 mins (5s sleep + 10s connect timeout) * 100. Reduce timeout to 5m of real time.
Diffstat (limited to 'vm')
-rw-r--r--vm/gce/gce.go4
1 files changed, 2 insertions, 2 deletions
diff --git a/vm/gce/gce.go b/vm/gce/gce.go
index 7d973fe2e..cf9009a10 100644
--- a/vm/gce/gce.go
+++ b/vm/gce/gce.go
@@ -165,7 +165,7 @@ func (pool *Pool) Create(workdir string, index int) (vmimpl.Instance, error) {
}
Logf(0, "wait instance to boot: %v (%v)", name, ip)
if err := pool.waitInstanceBoot(ip, sshKey, sshUser); err != nil {
- if output, err := pool.GCE.GetSerialPortOutput(name); err == nil {
+ if output, _ := pool.GCE.GetSerialPortOutput(name); len(output) != 0 {
err = errors.New(err.Error() + "\n\n" + output)
}
return nil, err
@@ -355,7 +355,7 @@ func (pool *Pool) waitInstanceBoot(ip, sshKey, sshUser string) error {
if pool.env.OS == "windows" {
pwd = "dir"
}
- for i := 0; i < 100; i++ {
+ for startTime := time.Now(); time.Since(startTime) < 5*time.Minute; {
if !vmimpl.SleepInterruptible(5 * time.Second) {
return fmt.Errorf("shutdown in progress")
}