Skip to content

Commit 69e5c5d

Browse files
committed
outofband/action_handlers: poller to collect inventory for install tasks
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.
1 parent 56b74a0 commit 69e5c5d

File tree

1 file changed

+19
-6
lines changed

1 file changed

+19
-6
lines changed

internal/outofband/action_handlers.go

Lines changed: 19 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ import (
1717
"github.com/pkg/errors"
1818
"github.com/prometheus/client_golang/prometheus"
1919
"github.com/sirupsen/logrus"
20+
"golang.org/x/exp/slices"
2021

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

521+
var installTask bool
522+
installTaskTypes := []string{
523+
string(bconsts.FirmwareInstallStepUploadInitiateInstall),
524+
string(bconsts.FirmwareInstallStepInstallUploaded),
525+
}
526+
527+
if slices.Contains(installTaskTypes, action.FirmwareInstallStep) {
528+
installTask = true
529+
}
530+
520531
startTS := time.Now()
521532

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

536547
tctx.Logger.WithFields(
537548
logrus.Fields{
538-
"component": action.Firmware.Component,
539-
"version": action.Firmware.Version,
540-
"bmc": tctx.Asset.BmcAddress,
549+
"component": action.Firmware.Component,
550+
"version": action.Firmware.Version,
551+
"bmc": tctx.Asset.BmcAddress,
552+
"step": action.FirmwareInstallStep,
553+
"installTask": installTask,
541554
}).Info("polling BMC for firmware task status")
542555

543556
// the prefix we'll be using for all the poll status updates
@@ -656,7 +669,7 @@ func (h *actionHandler) pollFirmwareTaskStatus(a sw.StateSwitch, c sw.Transition
656669
//
657670
// And so if we get an error and its a BMC component that was being updated, we wait for
658671
// the BMC to be available again and validate its firmware matches the one expected.
659-
if componentIsBMC(action.Firmware.Component) {
672+
if componentIsBMC(action.Firmware.Component) && installTask {
660673
tctx.Logger.WithFields(
661674
logrus.Fields{
662675
"bmc": tctx.Asset.BmcAddress,
@@ -721,7 +734,7 @@ func (h *actionHandler) pollFirmwareTaskStatus(a sw.StateSwitch, c sw.Transition
721734
}
722735

723736
// A BMC reset is required if the BMC install fails - to get it out of flash mode
724-
if componentIsBMC(action.Firmware.Component) && action.BMCResetOnInstallFailure {
737+
if componentIsBMC(action.Firmware.Component) && installTask && action.BMCResetOnInstallFailure {
725738
if err := h.powerCycleBMC(tctx); err != nil {
726739
tctx.Logger.WithFields(
727740
logrus.Fields{
@@ -744,7 +757,7 @@ func (h *actionHandler) pollFirmwareTaskStatus(a sw.StateSwitch, c sw.Transition
744757
case bconsts.Complete:
745758
// The BMC would reset itself and returning now would mean the next install fails,
746759
// wait until the BMC is available again and verify its on the expected version.
747-
if componentIsBMC(action.Firmware.Component) {
760+
if componentIsBMC(action.Firmware.Component) && installTask {
748761
inventory = true
749762
// re-initialize the client to make sure we're not re-using old sessions.
750763
tctx.DeviceQueryor.ReinitializeClient(tctx.Ctx)

0 commit comments

Comments
 (0)