Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

kola: include failed/stuck systemd units in error message directly #3823

Merged
merged 1 commit into from
Jun 24, 2024
Merged
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
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
Loading