Skip to content

Commit

Permalink
outofband/action_handlers: reset BMC based on task parameter
Browse files Browse the repository at this point in the history
  • Loading branch information
joelrebel committed Jul 12, 2023
1 parent 89172e1 commit 52aaa41
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 5 deletions.
19 changes: 15 additions & 4 deletions internal/outofband/action_handlers.go
Original file line number Diff line number Diff line change
Expand Up @@ -452,15 +452,18 @@ func (h *actionHandler) resetBMC(a sw.StateSwitch, c sw.TransitionArgs) error {
return err
}

if !action.BMCPowerCycleRequired {
// proceed with reset only if these flags are set
if !action.BMCPowerCycleRequired && !tctx.Task.Parameters.ResetBMCBeforeInstall {
return nil
}

tctx.Logger.WithFields(
logrus.Fields{
"component": action.Firmware.Component,
"bmc": tctx.Asset.BmcAddress,
}).Info("resetting BMC for firmware install")
"component": action.Firmware.Component,
"bmc": tctx.Asset.BmcAddress,
"task.Parameters.ResetBMCBeforeInstall": tctx.Task.Parameters.ResetBMCBeforeInstall,
"action.BMCPowerCycleRequired": action.BMCPowerCycleRequired,
}).Info("resetting BMC")

if !tctx.Dryrun {
if err := tctx.DeviceQueryor.ResetBMC(tctx.Ctx); err != nil {
Expand All @@ -472,6 +475,14 @@ func (h *actionHandler) resetBMC(a sw.StateSwitch, c sw.TransitionArgs) error {
}
}

// skip install status poll if this was a preinstall BMC reset
if tctx.Task.Parameters.ResetBMCBeforeInstall {
// set this to false to prevent the rest of the actions from attempting a preInstall BMC reset.
tctx.Task.Parameters.ResetBMCBeforeInstall = false

return nil
}

return h.pollFirmwareInstallStatus(a, c)
}

Expand Down
3 changes: 2 additions & 1 deletion internal/outofband/actions_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ func Test_NewActionStateMachine(t *testing.T) {
// TODO(joel): at some point we'd want to test if the nodes and edges
// in the transition rules match whats expected
assert.Equal(t, transitionOrder(), m.TransitionOrder())
assert.Len(t, transitionRules(), 10)
assert.Len(t, transitionRules(), 11)
}

func serverMux(t *testing.T, serveblob []byte) *http.ServeMux {
Expand Down Expand Up @@ -208,6 +208,7 @@ func Test_ActionStateMachine_Run_Fails(t *testing.T) {
transitionTypePowerOnDevice,
transitionTypeCheckInstalledFirmware,
transitionTypeDownloadFirmware,
transitionTypePreInstallResetBMC,
transitionTypeInitiatingInstallFirmware,
}

Expand Down

0 comments on commit 52aaa41

Please sign in to comment.