Skip to content

Commit 3823521

Browse files
committed
kola: include failed/stuck systemd units in error message directly
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.
1 parent 2b7b398 commit 3823521

File tree

1 file changed

+6
-15
lines changed

1 file changed

+6
-15
lines changed

mantle/platform/platform.go

Lines changed: 6 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -436,7 +436,7 @@ func checkSystemdUnitStuck(output string, m Machine) error {
436436
}
437437
NRestarts, _ = strconv.Atoi(string(out))
438438
if NRestarts >= 2 {
439-
return fmt.Errorf("systemd units %s has %v restarts", unit, NRestarts)
439+
return fmt.Errorf("systemd unit %s has %v restarts", unit, NRestarts)
440440
}
441441
}
442442
return nil
@@ -489,7 +489,6 @@ func CheckMachine(ctx context.Context, m Machine) error {
489489
// check systemd version on host to see if we can use `busctl --json=short`
490490
var systemdVer int
491491
var systemdCmd, failedUnitsCmd, activatingUnitsCmd string
492-
var systemdFailures bool
493492
minSystemdVer := 240
494493
out, stderr, err = m.SSH("rpm -q --queryformat='%{VERSION}\n' systemd")
495494
if err != nil {
@@ -511,31 +510,23 @@ func CheckMachine(ctx context.Context, m Machine) error {
511510
if err != nil {
512511
return fmt.Errorf("failed to query systemd for failed units: %s: %v: %s", out, err, stderr)
513512
}
514-
err = checkSystemdUnitFailures(string(out))
515-
if err != nil {
516-
plog.Error(err)
517-
systemdFailures = true
518-
}
513+
failed_err := checkSystemdUnitFailures(string(out))
519514

520515
// Ensure no systemd units stuck in activating state
521516
out, stderr, err = m.SSH(activatingUnitsCmd)
522517
if err != nil {
523518
return fmt.Errorf("failed to query systemd for activating units: %s: %v: %s", out, err, stderr)
524519
}
525-
err = checkSystemdUnitStuck(string(out), m)
526-
if err != nil {
527-
plog.Error(err)
528-
systemdFailures = true
529-
}
520+
stuck_err := checkSystemdUnitStuck(string(out), m)
530521

531-
if systemdFailures && !m.RuntimeConf().AllowFailedUnits {
522+
if (failed_err != nil || stuck_err != nil) && !m.RuntimeConf().AllowFailedUnits {
532523
if m.RuntimeConf().SSHOnTestFailure {
533-
plog.Error("dropping to shell: detected failed or stuck systemd units")
524+
plog.Errorf("dropping to shell: detected failed or stuck systemd units: %v; %v", failed_err, stuck_err)
534525
if err := Manhole(m); err != nil {
535526
plog.Errorf("failed to get terminal via ssh: %v", err)
536527
}
537528
}
538-
return fmt.Errorf("detected failed or stuck systemd units")
529+
return fmt.Errorf("detected failed or stuck systemd units: %v; %v", failed_err, stuck_err)
539530
}
540531

541532
return ctx.Err()

0 commit comments

Comments
 (0)