Skip to content

Commit ea4b418

Browse files
committed
Detect duplicaate update requests
1 parent bc153ee commit ea4b418

File tree

3 files changed

+30
-30
lines changed

3 files changed

+30
-30
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

+1
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ func (c *Conn) GetFirmwareInstallTaskQueued(ctx context.Context, component strin
4343
case strings.Contains(vendor, constants.Dell):
4444
task, err = c.getDellFirmwareInstallTaskScheduled(component)
4545
default:
46+
// TODO: correctly get an update task if there is one, using redfish API
4647
//task, err = c.redfishwrapper.Tasks(ctx)
4748
}
4849

0 commit comments

Comments
 (0)