aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLiz Prucka <lizprucka@google.com>2022-10-17 16:05:04 +0000
committerAleksandr Nogikh <wp32pw@gmail.com>2022-10-20 22:43:17 -0700
commit63e790dd3617b22ee48ea791ee759e27ac140bbf (patch)
tree829852daa6bc6466fd68b295cab4dacf4306821a
parent3a03e29438b147b9225177e67d5a56d2584bee36 (diff)
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().
-rw-r--r--vm/cuttlefish/cuttlefish.go9
1 files 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)
}