From 2d24bbb2259bd5064ccbea7a46c30591660b1a97 Mon Sep 17 00:00:00 2001 From: Dmitry Vyukov Date: Mon, 20 Nov 2017 11:57:42 +0100 Subject: 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. --- vm/gce/gce.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'vm') 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") } -- cgit mrf-deployment