Skip to content

Commit

Permalink
Use alternate URL if first fail
Browse files Browse the repository at this point in the history
  • Loading branch information
ofaurax committed Oct 26, 2023
1 parent 11e43b2 commit 8892008
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions providers/asrockrack/firmware.go
Original file line number Diff line number Diff line change
Expand Up @@ -72,9 +72,19 @@ func (a *ASRockRack) firmwareInstallBMC(ctx context.Context, reader io.Reader, f

// 2. upload firmware image file
a.log.V(2).WithValues("step", "2/4").Info("upload BMC firmware image")
err = a.uploadFirmware(ctx, "api/maintenance/firmware/firmware", reader, fileSize)

err = a.uploadFirmware(ctx, "api/maintenance/firmware", reader, fileSize)
if err != nil {
return errors.Wrap(err, "failed in step 2/4 - upload BMC firmware image")
// Try the special URL for e3c256d4i
a.log.V(2).WithValues("step", "2/4").Info("Try alternate URL")

Check warning on line 79 in providers/asrockrack/firmware.go

View check run for this annotation

Codecov / codecov/patch

providers/asrockrack/firmware.go#L79

Added line #L79 was not covered by tests
// Restart reader from start
reader.(*os.File).Seek(0, io.SeekStart)

Check failure on line 81 in providers/asrockrack/firmware.go

View workflow job for this annotation

GitHub Actions / lint

Error return value of `(*os.File).Seek` is not checked (errcheck)

Check failure on line 81 in providers/asrockrack/firmware.go

View workflow job for this annotation

GitHub Actions / lint

Error return value of `(*os.File).Seek` is not checked (errcheck)
err2 := a.uploadFirmware(ctx, "api/maintenance/firmware/firmware", reader, fileSize)
if err2 != nil {
a.log.V(2).WithValues("step", "2/4").Info("Alternate URL err:" + err2.Error())

Check warning on line 84 in providers/asrockrack/firmware.go

View check run for this annotation

Codecov / codecov/patch

providers/asrockrack/firmware.go#L81-L84

Added lines #L81 - L84 were not covered by tests
// if also in err, report first error
return errors.Wrap(err2, "failed in step 2/4 - upload BMC firmware image")

Check warning on line 86 in providers/asrockrack/firmware.go

View check run for this annotation

Codecov / codecov/patch

providers/asrockrack/firmware.go#L86

Added line #L86 was not covered by tests
}
}

// 3. BMC to verify the uploaded file
Expand Down

0 comments on commit 8892008

Please sign in to comment.