Skip to content

Commit

Permalink
Add parameter to bypass Open on FirmwareTaskStatus
Browse files Browse the repository at this point in the history
  • Loading branch information
ofaurax committed Nov 23, 2023
1 parent aef181c commit ecc737b
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 4 deletions.
2 changes: 1 addition & 1 deletion internal/model/model.go
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ type DeviceQueryor interface {

FirmwareUpload(ctx context.Context, component string, reader *os.File) (uploadVerifyTaskID string, err error)

FirmwareTaskStatus(ctx context.Context, kind bconsts.FirmwareInstallStep, component, taskID, installVersion string) (state, status string, err error)
FirmwareTaskStatus(ctx context.Context, kind bconsts.FirmwareInstallStep, component, taskID, installVersion string, tryOpen bool) (state, status string, err error)

FirmwareInstallUploaded(ctx context.Context, component, uploadVerifyTaskID string) (installTaskID string, err error)
}
1 change: 1 addition & 0 deletions internal/outofband/action_handlers.go
Original file line number Diff line number Diff line change
Expand Up @@ -595,6 +595,7 @@ func (h *actionHandler) pollFirmwareTaskStatus(a sw.StateSwitch, c sw.Transition
action.Firmware.Component,
action.BMCTaskID,
action.Firmware.Version,
true, // need to be false for AsRockRack E3C256D4ID-NL
)

tctx.Logger.WithFields(
Expand Down
1 change: 1 addition & 0 deletions internal/outofband/action_handlers_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -325,6 +325,7 @@ func TestPollFirmwareInstallStatus(t *testing.T) {
gomock.Any(),
gomock.Any(),
gomock.Any(),
gomock.Any(),
).AnyTimes().Return(tc.state, "some status", tc.errorContains)

if err := handler.pollFirmwareTaskStatus(&action, handlerCtx); err != nil {
Expand Down
2 changes: 2 additions & 0 deletions internal/outofband/actions_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -423,6 +423,7 @@ func TestActionStateMachine(t *testing.T) {
gomock.Any(),
gomock.Any(),
gomock.Any(),
gomock.Any(),
).AnyTimes().Return(bconsts.FirmwareInstallComplete, "some status", nil)

return ctrl, q
Expand Down Expand Up @@ -469,6 +470,7 @@ func TestActionStateMachine(t *testing.T) {
gomock.Any(),
gomock.Any(),
gomock.Any(),
gomock.Any(),
).AnyTimes().Return(bconsts.FirmwareInstallFailed, "some status", nil)

return ctrl, q
Expand Down
8 changes: 5 additions & 3 deletions internal/outofband/bmc.go
Original file line number Diff line number Diff line change
Expand Up @@ -167,9 +167,11 @@ func (b *bmc) FirmwareInstall(ctx context.Context, componentSlug string, force b
}

// FirmwareTaskStatus looks up the firmware upload/install state and status values
func (b *bmc) FirmwareTaskStatus(ctx context.Context, kind bconsts.FirmwareInstallStep, component, taskID, installVersion string) (state, status string, err error) {
if err := b.Open(ctx); err != nil {
return "", "", errors.Wrap(ErrBMCQuery, err.Error())
func (b *bmc) FirmwareTaskStatus(ctx context.Context, kind bconsts.FirmwareInstallStep, component, taskID, installVersion string, tryOpen bool) (state, status string, err error) {
if tryOpen {
if err := b.Open(ctx); err != nil {
return "", "", errors.Wrap(ErrBMCQuery, err.Error())
}
}

return b.client.FirmwareTaskStatus(ctx, kind, component, taskID, installVersion)
Expand Down

0 comments on commit ecc737b

Please sign in to comment.