Skip to content

Commit

Permalink
inband: powercycle in the final component fw install action
Browse files Browse the repository at this point in the history
instead of powercycling post each component firwmare install
  • Loading branch information
joelrebel committed Aug 20, 2024
1 parent 237d2e1 commit 41f987a
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 9 deletions.
21 changes: 12 additions & 9 deletions internal/inband/actions.go
Original file line number Diff line number Diff line change
Expand Up @@ -108,24 +108,23 @@ func (i *ActionHandler) ComposeAction(ctx context.Context, actionCtx *runner.Act
Info("No firmware install requirements were identified for component")
}

steps, err := i.composeSteps(required)
if err != nil {
return nil, errors.Wrap(errCompose, err.Error())
}

action := &model.Action{
i.handler.action = &model.Action{
InstallMethod: model.InstallMethodInband,
Firmware: *actionCtx.Firmware,
ForceInstall: actionCtx.Task.Parameters.ForceInstall,
Steps: steps,
First: actionCtx.First,
Last: actionCtx.Last,
Component: component,
}

i.handler.action = action
steps, err := i.composeSteps(required)
if err != nil {
return nil, errors.Wrap(errCompose, err.Error())
}

i.handler.action.Steps = steps

return action, nil
return i.handler.action, nil
}

func initHandler(actionCtx *runner.ActionHandlerContext, queryor device.InbandQueryor) *handler {
Expand Down Expand Up @@ -158,6 +157,10 @@ func (i *ActionHandler) composeSteps(required *imodel.UpdateRequirements) (model
final = append(final, install...)

if required != nil && required.PostInstallHostPowercycle {
i.handler.task.Data.HostPowercycleRequired = true
}

if i.handler.action.Last && i.handler.task.Data.HostPowercycleRequired {
powerCycle, errDef := i.definitions().ByName(powerCycleServer)
if errDef != nil {
return nil, err
Expand Down
7 changes: 7 additions & 0 deletions internal/inband/actions_handlers.go
Original file line number Diff line number Diff line change
Expand Up @@ -196,6 +196,7 @@ func (h *handler) installFirmware(ctx context.Context) error {
h.action.FirmwareTempFile,
h.action.ForceInstall,
); err != nil {
// component update could not be applied because it requires a host power cycle
if errors.Is(err, iutils.ErrRebootRequired) {
h.logger.WithFields(
logrus.Fields{
Expand All @@ -204,6 +205,12 @@ func (h *handler) installFirmware(ctx context.Context) error {
"version": h.firmware.Version,
"msg": err.Error(),
}).Info("firmware install requires a server power cycle")

// force power cycle if we're on the last action
if h.action.Last {
return h.powerCycleServer(ctx)
}

return nil
}

Expand Down
4 changes: 4 additions & 0 deletions internal/model/task.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,10 @@ func (t *Task) MustMarshal() json.RawMessage {

type TaskData struct {
StructVersion string `json:"struct_version"`

// This flag is set when a action requires a host power cycle.
HostPowercycleRequired bool `json:"host_powercycle_required,omitempty"`

// Flasher determines the firmware to be installed for each component based on the firmware plan method.
FirmwarePlanMethod FirmwarePlanMethod `json:"firmware_plan_method,omitempty"`

Expand Down
1 change: 1 addition & 0 deletions internal/worker/task_handler_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -382,6 +382,7 @@ func TestPlanInstall_Inband(t *testing.T) {
Task: &model.Task{
ID: taskID,
WorkerID: registry.GetID("test-app").String(),
Data: &model.TaskData{},
Parameters: &rctypes.FirmwareInstallTaskParameters{
AssetID: serverID,
ForceInstall: true,
Expand Down

0 comments on commit 41f987a

Please sign in to comment.