Skip to content

Commit

Permalink
providers/redfish: Detect duplicate update requests
Browse files Browse the repository at this point in the history
  • Loading branch information
ofaurax committed Sep 13, 2023
1 parent 0fe4a15 commit 2e973ca
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 20 deletions.
37 changes: 18 additions & 19 deletions providers/redfish/firmware.go
Original file line number Diff line number Diff line change
Expand Up @@ -69,26 +69,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 "", errors.Wrap(bmclibErrs.ErrFirmwareInstall, err.Error())
// }
//
// 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 "", errors.Wrap(bmclibErrs.ErrFirmwareInstall, err.Error())
}

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
3 changes: 2 additions & 1 deletion providers/redfish/tasks.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ func (c *Conn) activeTask(ctx context.Context) (*gofishrf.Task, error) {
return nil, err
}

// TODO: correctly get an update task if there is one, using redfish API
for _, t := range tasks {
fmt.Println(t.TaskState)
fmt.Println(t.TaskStatus)
Expand All @@ -43,7 +44,7 @@ func (c *Conn) GetFirmwareInstallTaskQueued(ctx context.Context, component strin
case strings.Contains(vendor, constants.Dell):
task, err = c.getDellFirmwareInstallTaskScheduled(component)
default:
//task, err = c.redfishwrapper.Tasks(ctx)
task, err = c.activeTask(ctx)
}

if err != nil {
Expand Down

0 comments on commit 2e973ca

Please sign in to comment.