Skip to content
This repository was archived by the owner on May 7, 2021. It is now read-only.
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 14 additions & 4 deletions platform/platform.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import (
"fmt"
"io"
"path/filepath"
"strings"
"sync"
"time"

Expand Down Expand Up @@ -326,16 +327,25 @@ func CheckMachine(ctx context.Context, m Machine) error {
}
out, stderr, err := m.SSH("systemctl is-system-running")
if !bytes.Contains([]byte("initializing starting running stopping"), out) {
return nil // stop retrying if the system went haywire
return fmt.Errorf("machine reached a bad state: %s, %v, %s", out, err, stderr)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We'll need to build a mechanism for detecting if we're running kola spawn. As this code currently is we cannot spawn into machines in a degraded state any longer with this patch.

}
if err != nil {
return fmt.Errorf("could not check if machine is running: %s: %v: %s", out, err, stderr)
if bytes.Contains([]byte("starting"), out) {
if jobs, _, err2 := m.SSH("systemctl list-jobs"); err2 == nil {
return fmt.Errorf("machine did not finish starting in time. Active jobs:\n%s", string(jobs))
}
}
return fmt.Errorf("machine is not marked running yet: %s: %v: %s", out, err, stderr)
}
return nil
}

if err := util.Retry(sshRetries, sshTimeout, sshChecker); err != nil {
return fmt.Errorf("ssh unreachable: %v", err)
shouldRetry := func(e error) bool {
return !strings.HasPrefix(e.Error(), "machine reached a bad state")
}

if err := util.RetryConditional(sshRetries, sshTimeout, shouldRetry, sshChecker); err != nil {
return fmt.Errorf("machine never became ready: %v", err)
}

out, stderr, err := m.SSH(`. /etc/os-release && echo "$ID-$VARIANT_ID"`)
Expand Down