Skip to content

Commit

Permalink
kola: include failed/stuck systemd units in error message directly
Browse files Browse the repository at this point in the history
Instead of separately logging which systemd units are stuck and failed,
just include it in the fatal error we eventually emit when we print
the test failure. Otherwise it's not easy to match logged messages with
failures when running tests in parallel.
  • Loading branch information
jlebon committed Jun 24, 2024
1 parent 2b7b398 commit 3823521
Showing 1 changed file with 6 additions and 15 deletions.
21 changes: 6 additions & 15 deletions mantle/platform/platform.go
Original file line number Diff line number Diff line change
Expand Up @@ -436,7 +436,7 @@ func checkSystemdUnitStuck(output string, m Machine) error {
}
NRestarts, _ = strconv.Atoi(string(out))
if NRestarts >= 2 {
return fmt.Errorf("systemd units %s has %v restarts", unit, NRestarts)
return fmt.Errorf("systemd unit %s has %v restarts", unit, NRestarts)
}
}
return nil
Expand Down Expand Up @@ -489,7 +489,6 @@ func CheckMachine(ctx context.Context, m Machine) error {
// check systemd version on host to see if we can use `busctl --json=short`
var systemdVer int
var systemdCmd, failedUnitsCmd, activatingUnitsCmd string
var systemdFailures bool
minSystemdVer := 240
out, stderr, err = m.SSH("rpm -q --queryformat='%{VERSION}\n' systemd")
if err != nil {
Expand All @@ -511,31 +510,23 @@ func CheckMachine(ctx context.Context, m Machine) error {
if err != nil {
return fmt.Errorf("failed to query systemd for failed units: %s: %v: %s", out, err, stderr)
}
err = checkSystemdUnitFailures(string(out))
if err != nil {
plog.Error(err)
systemdFailures = true
}
failed_err := checkSystemdUnitFailures(string(out))

// Ensure no systemd units stuck in activating state
out, stderr, err = m.SSH(activatingUnitsCmd)
if err != nil {
return fmt.Errorf("failed to query systemd for activating units: %s: %v: %s", out, err, stderr)
}
err = checkSystemdUnitStuck(string(out), m)
if err != nil {
plog.Error(err)
systemdFailures = true
}
stuck_err := checkSystemdUnitStuck(string(out), m)

if systemdFailures && !m.RuntimeConf().AllowFailedUnits {
if (failed_err != nil || stuck_err != nil) && !m.RuntimeConf().AllowFailedUnits {
if m.RuntimeConf().SSHOnTestFailure {
plog.Error("dropping to shell: detected failed or stuck systemd units")
plog.Errorf("dropping to shell: detected failed or stuck systemd units: %v; %v", failed_err, stuck_err)
if err := Manhole(m); err != nil {
plog.Errorf("failed to get terminal via ssh: %v", err)
}
}
return fmt.Errorf("detected failed or stuck systemd units")
return fmt.Errorf("detected failed or stuck systemd units: %v; %v", failed_err, stuck_err)
}

return ctx.Err()
Expand Down

0 comments on commit 3823521

Please sign in to comment.