From 1bd1bc7d21be9920a31f48d2e962dc74274d216f Mon Sep 17 00:00:00 2001 From: Aleksandr Nogikh Date: Fri, 26 Sep 2025 15:31:32 +0200 Subject: vm: use error wrapping to detect ssh connection errors This is a much cleaner logic than string matching. --- vm/vmimpl/util.go | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'vm/vmimpl') diff --git a/vm/vmimpl/util.go b/vm/vmimpl/util.go index 729e78de6..a0e3ce841 100644 --- a/vm/vmimpl/util.go +++ b/vm/vmimpl/util.go @@ -58,13 +58,15 @@ func WaitForSSH(timeout time.Duration, opts SSHOptions, OS string, stop chan err } if time.Since(startTime) > timeout { return &osutil.VerboseError{ - Err: fmt.Errorf("can't ssh into the instance"), + Err: ErrCantSSH, Output: []byte(err.Error()), } } } } +var ErrCantSSH = fmt.Errorf("can't ssh into the instance") + func SSHArgs(debug bool, sshKey string, port int, systemSSHCfg bool) []string { return sshArgs(debug, sshKey, "-p", port, 0, systemSSHCfg) } -- cgit mrf-deployment