Skip to content

Commit

Permalink
outofband/actions: when required reset BMC during polling
Browse files Browse the repository at this point in the history
To reset or not is determined by the bmclib provider, which is set on
the Action when the firmware install is planned.
  • Loading branch information
joelrebel committed Dec 5, 2023
1 parent c14c89d commit 1ffd534
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 0 deletions.
35 changes: 35 additions & 0 deletions internal/outofband/action_handlers.go
Original file line number Diff line number Diff line change
Expand Up @@ -702,6 +702,24 @@ func (h *actionHandler) pollFirmwareTaskStatus(a sw.StateSwitch, c sw.Transition
)
}

// A BMC reset is required if the BMC install fails - to get it out of flash mode
if componentIsBMC(action.Firmware.Component) && action.BMCResetOnInstallFailure {
if err := h.powerCycleBMC(tctx); err != nil {
tctx.Logger.WithFields(
logrus.Fields{
"bmc": tctx.Asset.BmcAddress,
"component": action.Firmware.Component,
"err": err.Error(),
}).Debug("install failure required a BMC reset, reset returned error")
}

tctx.Logger.WithFields(
logrus.Fields{
"bmc": tctx.Asset.BmcAddress,
"component": action.Firmware.Component,
}).Debug("BMC reset for failed BMC firmware install")
}

return errors.Wrap(ErrFirmwareInstallFailed, errMsg)

// return nil when install is complete
Expand All @@ -711,6 +729,23 @@ func (h *actionHandler) pollFirmwareTaskStatus(a sw.StateSwitch, c sw.Transition
if componentIsBMC(action.Firmware.Component) {
inventory = true

if action.BMCResetPostInstall {
if errBmcReset := h.powerCycleBMC(tctx); errBmcReset != nil {
tctx.Logger.WithFields(
logrus.Fields{
"bmc": tctx.Asset.BmcAddress,
"component": action.Firmware.Component,
"err": errBmcReset.Error(),
}).Debug("install success required a BMC reset, reset returned error")
}

tctx.Logger.WithFields(
logrus.Fields{
"bmc": tctx.Asset.BmcAddress,
"component": action.Firmware.Component,
}).Debug("BMC reset for successful BMC firmware install")
}

continue
}

Expand Down
6 changes: 6 additions & 0 deletions internal/outofband/actions.go
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,12 @@ func convFirmwareInstallSteps(required []bconsts.FirmwareInstallStep, defined Tr
transitions := Transitions{}

for _, s := range required {
// TODO: turn FirmwareInstalSteps into FirmwareInstallProperties with fields for these non step parameters
if s == bconsts.FirmwareInstallStepResetBMCOnInstallFailure ||
s == bconsts.FirmwareInstallStepResetBMCPostInstall {
continue
}

transitionName, exists := m[s]
if !exists {
return nil, errors.Wrap(errUnsupported, string(s))
Expand Down

0 comments on commit 1ffd534

Please sign in to comment.