mantle/platform: always run systemd unit checks
In this way we'll always run the unit checks (a change) but we'll continue to
only fail if we are not allowing failed units.
@@ -502,6 +502,7 @@ 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 {
@@ -518,7 +519,6 @@ func CheckMachine(ctx context.Context, m Machine) error {
failedUnitsCmd = strings.Replace(systemdCmd, "status", "failed", -1)
activatingUnitsCmd = strings.Replace(systemdCmd, "status", "activating", -1)
- if !m.RuntimeConf().AllowFailedUnits {
// Ensure no systemd units failed during boot
out, stderr, err = m.SSH(failedUnitsCmd)
if err != nil {
@@ -526,7 +526,8 @@ func CheckMachine(ctx context.Context, m Machine) error {
}
err = checkSystemdUnitFailures(string(out), distribution)
if err != nil {
- return err
+ plog.Error(err)
+ systemdFailures = true
}
// Ensure no systemd units stuck in activating state
@@ -536,8 +537,12 @@ func CheckMachine(ctx context.Context, m Machine) error {
}
err = checkSystemdUnitStuck(string(out), m)
if err != nil {
- return err
+ plog.Error(err)
+ systemdFailures = true
}
+
+ if systemdFailures && !m.RuntimeConf().AllowFailedUnits {
+ return fmt.Errorf("detected failed or stuck systemd units")
}
return ctx.Err()
