From 9ab80e53fec84831ac52bab164428bcb532b10d6 Mon Sep 17 00:00:00 2001 From: Olivier FAURAX Date: Fri, 10 Nov 2023 14:52:58 +0100 Subject: [PATCH] seek before go routine --- providers/asrockrack/firmware.go | 6 ------ providers/asrockrack/helpers.go | 5 +++++ 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/providers/asrockrack/firmware.go b/providers/asrockrack/firmware.go index 6b23e72f..25cdbc3d 100644 --- a/providers/asrockrack/firmware.go +++ b/providers/asrockrack/firmware.go @@ -74,9 +74,6 @@ func (a *ASRockRack) FirmwareInstallStatus(ctx context.Context, installVersion, func (a *ASRockRack) firmwareInstallBMC(ctx context.Context, reader io.Reader, fileSize int64) error { var err error - mybytes, err := io.ReadAll(reader) - fmt.Printf("ReadAll reader before FRU len:%d\n", len(mybytes)) - // 0. take the model so that we use a different endpoint on E3C256D4ID-NL device := common.NewDevice() device.Metadata = map[string]string{} @@ -85,9 +82,6 @@ func (a *ASRockRack) firmwareInstallBMC(ctx context.Context, reader io.Reader, f return errors.Wrap(err, "failed to get model in step 0/4") } - mybytes, err = io.ReadAll(reader) - fmt.Printf("ReadAll reader afterFRU len:%d\n", len(mybytes)) - // 1. set the device to flash mode - prepares the flash // Beware: this locks some capabilities, e.g. the access to fruAttributes a.log.V(2).WithValues("step", "1/4").Info("set device to flash mode, takes a minute...") diff --git a/providers/asrockrack/helpers.go b/providers/asrockrack/helpers.go index 0c0de3e9..1bfb1956 100644 --- a/providers/asrockrack/helpers.go +++ b/providers/asrockrack/helpers.go @@ -229,6 +229,11 @@ func (a *ASRockRack) uploadFirmware(ctx context.Context, endpoint string, fwRead mybytes, err := io.ReadAll(fwReader) fmt.Printf("ReadAll fwReader len:%d\n", len(mybytes)) + if file, ok := fwReader.(*os.File); ok { + fmt.Printf("Seek before go routine\n") + file.Seek(0, 0) + } + // setup pipe pipeReader, pipeWriter := io.Pipe() defer pipeReader.Close()