From 69e5c5d1c46c9002a1fbc6b5525434c8064e27d4 Mon Sep 17 00:00:00 2001 From: Joel Rebello Date: Thu, 25 Apr 2024 13:37:28 +0200 Subject: [PATCH] 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. --- internal/outofband/action_handlers.go | 25 +++++++++++++++++++------ 1 file changed, 19 insertions(+), 6 deletions(-) diff --git a/internal/outofband/action_handlers.go b/internal/outofband/action_handlers.go index f3b50cad..d7bb07d6 100644 --- a/internal/outofband/action_handlers.go +++ b/internal/outofband/action_handlers.go @@ -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" ) @@ -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 @@ -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 @@ -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, @@ -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{ @@ -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)