Skip to content

Commit

Permalink
Detect duplicaate update requests
Browse files Browse the repository at this point in the history
  • Loading branch information
ofaurax committed Sep 5, 2023
1 parent bc153ee commit ea4b418
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 30 deletions.
37 changes: 18 additions & 19 deletions providers/redfish/firmware.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,26 +62,25 @@ func (c *Conn) FirmwareInstall(ctx context.Context, component, applyAt string, f
return "", errors.Wrap(errInsufficientCtxTimeout, " "+time.Until(ctxDeadline).String())
}

// TODO; uncomment once obmc support is implemented for tasks
// list redfish firmware install task if theres one present
// task, err := c.GetFirmwareInstallTaskQueued(ctx, component)
// if err != nil {
// return "", err
// }
//
// if task != nil {
// msg := fmt.Sprintf("task for %s firmware install present: %s", component, task.ID)
// c.Log.V(2).Info("warn", msg)
//
// if forceInstall {
// err = c.purgeQueuedFirmwareInstallTask(ctx, component)
// if err != nil {
// return "", errors.Wrap(bmclibErrs.ErrFirmwareInstall, err.Error())
// }
// } else {
// return "", errors.Wrap(bmclibErrs.ErrFirmwareInstall, msg)
// }
// }
task, err := c.GetFirmwareInstallTaskQueued(ctx, component)
if err != nil {
return "", err
}

if task != nil {
msg := fmt.Sprintf("task for %s firmware install present: %s", component, task.ID)
c.Log.V(2).Info("warn", msg)

if forceInstall {
err = c.purgeQueuedFirmwareInstallTask(ctx, component)
if err != nil {
return "", errors.Wrap(bmclibErrs.ErrFirmwareInstall, err.Error())
}
} else {
return "", errors.Wrap(bmclibErrs.ErrFirmwareInstall, msg)
}
}

// override the gofish HTTP client timeout,
// since the context timeout is set at Open() and is at a lower value than required for this operation.
Expand Down
22 changes: 11 additions & 11 deletions providers/redfish/firmware_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -112,17 +112,17 @@ func TestFirmwareInstall(t *testing.T) {
"invalid applyAt parameter",
"applyAt parameter invalid",
},
//{
// common.SlugBIOS,
// constants.FirmwareApplyOnReset,
// false,
// true,
// fh,
// "467696020275",
// bmclibErrs.ErrFirmwareInstall,
// "task for BIOS firmware install present",
// "task ID exists",
//},
{
common.SlugBIOS,
constants.FirmwareApplyOnReset,
false,
true,
fh,
"467696020275",
bmclibErrs.ErrFirmwareInstall,
"task for BIOS firmware install present",
"task ID exists",
},
{
common.SlugBIOS,
constants.FirmwareApplyOnReset,
Expand Down
1 change: 1 addition & 0 deletions providers/redfish/tasks.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ func (c *Conn) GetFirmwareInstallTaskQueued(ctx context.Context, component strin
case strings.Contains(vendor, constants.Dell):
task, err = c.getDellFirmwareInstallTaskScheduled(component)
default:
// TODO: correctly get an update task if there is one, using redfish API
//task, err = c.redfishwrapper.Tasks(ctx)
}

Expand Down

0 comments on commit ea4b418

Please sign in to comment.