diff options
| author | Aleksandr Nogikh <nogikh@google.com> | 2025-09-26 15:31:32 +0200 |
|---|---|---|
| committer | Aleksandr Nogikh <nogikh@google.com> | 2025-10-01 14:41:08 +0000 |
| commit | 1bd1bc7d21be9920a31f48d2e962dc74274d216f (patch) | |
| tree | 1645860e7374ab650321089f1f884c1ed8631c0a /vm/qemu | |
| parent | 12039a0e63377e86fa1b5adc3d327d6e07f23a32 (diff) | |
vm: use error wrapping to detect ssh connection errors
This is a much cleaner logic than string matching.
Diffstat (limited to 'vm/qemu')
| -rw-r--r-- | vm/qemu/qemu.go | 7 |
1 files changed, 3 insertions, 4 deletions
diff --git a/vm/qemu/qemu.go b/vm/qemu/qemu.go index 6714703fe..55473a419 100644 --- a/vm/qemu/qemu.go +++ b/vm/qemu/qemu.go @@ -7,6 +7,7 @@ import ( "bytes" "context" "encoding/json" + "errors" "fmt" "io" "net" @@ -348,10 +349,8 @@ func (pool *Pool) Create(ctx context.Context, workdir string, index int) (vmimpl if err == nil { return inst, nil } - if strings.Contains(err.Error(), "can't ssh into the instance") { - // If there was a boot error, immediately return it. - // In this case, the string search below also matches against boot time output, - // and e.g. "Device or resource busy" is quite often in there. + if errors.Is(err, vmimpl.ErrCantSSH) { + // It is most likely a boot crash, just return the error as is. return nil, err } // Older qemu prints "could", newer -- "Could". |
