Skip to content

Commit 133e324

Browse files
committed
Detect duplicate update requests
1 parent bc153ee commit 133e324

File tree

3 files changed

+31
-31
lines changed

3 files changed

+31
-31
lines changed

providers/redfish/firmware.go

+18-19
Original file line numberDiff line numberDiff line change
@@ -62,26 +62,25 @@ func (c *Conn) FirmwareInstall(ctx context.Context, component, applyAt string, f
6262
return "", errors.Wrap(errInsufficientCtxTimeout, " "+time.Until(ctxDeadline).String())
6363
}
6464

65-
// TODO; uncomment once obmc support is implemented for tasks
6665
// list redfish firmware install task if theres one present
67-
// task, err := c.GetFirmwareInstallTaskQueued(ctx, component)
68-
// if err != nil {
69-
// return "", err
70-
// }
71-
//
72-
// if task != nil {
73-
// msg := fmt.Sprintf("task for %s firmware install present: %s", component, task.ID)
74-
// c.Log.V(2).Info("warn", msg)
75-
//
76-
// if forceInstall {
77-
// err = c.purgeQueuedFirmwareInstallTask(ctx, component)
78-
// if err != nil {
79-
// return "", errors.Wrap(bmclibErrs.ErrFirmwareInstall, err.Error())
80-
// }
81-
// } else {
82-
// return "", errors.Wrap(bmclibErrs.ErrFirmwareInstall, msg)
83-
// }
84-
// }
66+
task, err := c.GetFirmwareInstallTaskQueued(ctx, component)
67+
if err != nil {
68+
return "", err
69+
}
70+
71+
if task != nil {
72+
msg := fmt.Sprintf("task for %s firmware install present: %s", component, task.ID)
73+
c.Log.V(2).Info("warn", msg)
74+
75+
if forceInstall {
76+
err = c.purgeQueuedFirmwareInstallTask(ctx, component)
77+
if err != nil {
78+
return "", errors.Wrap(bmclibErrs.ErrFirmwareInstall, err.Error())
79+
}
80+
} else {
81+
return "", errors.Wrap(bmclibErrs.ErrFirmwareInstall, msg)
82+
}
83+
}
8584

8685
// override the gofish HTTP client timeout,
8786
// since the context timeout is set at Open() and is at a lower value than required for this operation.

providers/redfish/firmware_test.go

+11-11
Original file line numberDiff line numberDiff line change
@@ -112,17 +112,17 @@ func TestFirmwareInstall(t *testing.T) {
112112
"invalid applyAt parameter",
113113
"applyAt parameter invalid",
114114
},
115-
//{
116-
// common.SlugBIOS,
117-
// constants.FirmwareApplyOnReset,
118-
// false,
119-
// true,
120-
// fh,
121-
// "467696020275",
122-
// bmclibErrs.ErrFirmwareInstall,
123-
// "task for BIOS firmware install present",
124-
// "task ID exists",
125-
//},
115+
{
116+
common.SlugBIOS,
117+
constants.FirmwareApplyOnReset,
118+
false,
119+
true,
120+
fh,
121+
"467696020275",
122+
bmclibErrs.ErrFirmwareInstall,
123+
"task for BIOS firmware install present",
124+
"task ID exists",
125+
},
126126
{
127127
common.SlugBIOS,
128128
constants.FirmwareApplyOnReset,

providers/redfish/tasks.go

+2-1
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ func (c *Conn) activeTask(ctx context.Context) (*gofishrf.Task, error) {
2020
return nil, err
2121
}
2222

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

4950
if err != nil {

0 commit comments

Comments
 (0)