From 63e790dd3617b22ee48ea791ee759e27ac140bbf Mon Sep 17 00:00:00 2001 From: Liz Prucka Date: Mon, 17 Oct 2022 16:05:04 +0000 Subject: vm/cuttlefish: ignore timeout in Forward() The current refactor does not return vmimpl.ErrTimeout() when a timeout occurs. The error handling has been changed to parse the return string for the "timedout after" from osutil.RunCmd(). --- vm/cuttlefish/cuttlefish.go | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/vm/cuttlefish/cuttlefish.go b/vm/cuttlefish/cuttlefish.go index f6f61ee16..3608b73dc 100644 --- a/vm/cuttlefish/cuttlefish.go +++ b/vm/cuttlefish/cuttlefish.go @@ -12,6 +12,7 @@ package cuttlefish import ( "fmt" + "os/exec" "path/filepath" "time" @@ -138,8 +139,12 @@ func (inst *instance) Forward(port int) (string, error) { return "", fmt.Errorf("failed to get IP/port from GCE instance: %s", err) } - cmd := fmt.Sprintf("nohup socat TCP-LISTEN:%d,fork TCP:%s", port, hostForward) - if err := inst.runOnHost(time.Second, cmd); err != nil && err != vmimpl.ErrTimeout { + // Run socat in the background. This hangs when run from runOnHost(). + cmdStr := fmt.Sprintf("nohup socat TCP-LISTEN:%d,fork TCP:%s", port, hostForward) + cmdArgs := append([]string{"-f"}, inst.sshArgs(cmdStr)...) + cmd := exec.Command("ssh", cmdArgs...) + cmd.Dir = "/root" + if err := cmd.Run(); err != nil { return "", fmt.Errorf("unable to forward port on host: %s", err) } -- cgit mrf-deployment