Skip to content

Commit

Permalink
outofband/action_handlers: poller to collect inventory for install tasks
Browse files Browse the repository at this point in the history
This fixes the poller failure when comparing the installed firmware with
the expected for BMC firmware - for firmware upload verify tasks.

The poller is invoked for both install and firmware upload verify tasks,
it did not differentiate between the two before attempting to collect
inventory from the BMC to verify the installed firmware matches the
expected. When verifying a firmware upload task, an inventory and
version comparision is not required.
  • Loading branch information
joelrebel committed Apr 25, 2024
1 parent 56b74a0 commit 69e5c5d
Showing 1 changed file with 19 additions and 6 deletions.
25 changes: 19 additions & 6 deletions internal/outofband/action_handlers.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import (
"github.com/pkg/errors"
"github.com/prometheus/client_golang/prometheus"
"github.com/sirupsen/logrus"
"golang.org/x/exp/slices"

bconsts "github.com/bmc-toolbox/bmclib/v2/constants"
)
Expand Down Expand Up @@ -517,6 +518,16 @@ func (h *actionHandler) pollFirmwareTaskStatus(a sw.StateSwitch, c sw.Transition
return nil
}

var installTask bool
installTaskTypes := []string{
string(bconsts.FirmwareInstallStepUploadInitiateInstall),
string(bconsts.FirmwareInstallStepInstallUploaded),
}

if slices.Contains(installTaskTypes, action.FirmwareInstallStep) {
installTask = true
}

startTS := time.Now()

// number of status queries attempted
Expand All @@ -535,9 +546,11 @@ func (h *actionHandler) pollFirmwareTaskStatus(a sw.StateSwitch, c sw.Transition

tctx.Logger.WithFields(
logrus.Fields{
"component": action.Firmware.Component,
"version": action.Firmware.Version,
"bmc": tctx.Asset.BmcAddress,
"component": action.Firmware.Component,
"version": action.Firmware.Version,
"bmc": tctx.Asset.BmcAddress,
"step": action.FirmwareInstallStep,
"installTask": installTask,
}).Info("polling BMC for firmware task status")

// the prefix we'll be using for all the poll status updates
Expand Down Expand Up @@ -656,7 +669,7 @@ func (h *actionHandler) pollFirmwareTaskStatus(a sw.StateSwitch, c sw.Transition
//
// And so if we get an error and its a BMC component that was being updated, we wait for
// the BMC to be available again and validate its firmware matches the one expected.
if componentIsBMC(action.Firmware.Component) {
if componentIsBMC(action.Firmware.Component) && installTask {
tctx.Logger.WithFields(
logrus.Fields{
"bmc": tctx.Asset.BmcAddress,
Expand Down Expand Up @@ -721,7 +734,7 @@ 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 componentIsBMC(action.Firmware.Component) && installTask && action.BMCResetOnInstallFailure {
if err := h.powerCycleBMC(tctx); err != nil {
tctx.Logger.WithFields(
logrus.Fields{
Expand All @@ -744,7 +757,7 @@ func (h *actionHandler) pollFirmwareTaskStatus(a sw.StateSwitch, c sw.Transition
case bconsts.Complete:
// The BMC would reset itself and returning now would mean the next install fails,
// wait until the BMC is available again and verify its on the expected version.
if componentIsBMC(action.Firmware.Component) {
if componentIsBMC(action.Firmware.Component) && installTask {
inventory = true
// re-initialize the client to make sure we're not re-using old sessions.
tctx.DeviceQueryor.ReinitializeClient(tctx.Ctx)
Expand Down

0 comments on commit 69e5c5d

Please sign in to comment.