[VOL-5374] go version upgrade to 1.23.1 and few other package versions upgrade
Signed-off-by: akashreddyk <akash.kankanala@radisys.com>
Change-Id: I50531e8febdc00b335ebbe5a4b1099fc3bf6d5b4
diff --git a/internal/pkg/swupg/adapter_download_manager.go b/internal/pkg/swupg/adapter_download_manager.go
index 4c6f291..8dabf08 100755
--- a/internal/pkg/swupg/adapter_download_manager.go
+++ b/internal/pkg/swupg/adapter_download_manager.go
@@ -45,8 +45,8 @@
// AdapterDownloadManager structure holds information needed for downloading to and storing images within the adapter
type AdapterDownloadManager struct {
- mutexDownloadImageDsc sync.RWMutex
downloadImageDscSlice []*voltha.ImageDownload
+ mutexDownloadImageDsc sync.RWMutex
}
// NewAdapterDownloadManager constructor returns a new instance of a AdapterDownloadManager
@@ -200,7 +200,7 @@
}
// Create the file
- aLocalPathName := aFilePath + "/" + aFileName
+ aLocalPathName := filepath.Clean(filepath.Join(aFilePath, aFileName))
file, err := os.Create(aLocalPathName)
if err != nil {
logger.Errorw(ctx, "could not create local file", log.Fields{"path_file": aLocalPathName, "error": err})
@@ -269,7 +269,7 @@
return nil, err
}
defer func() {
- err := file.Close()
+ err = file.Close()
if err != nil {
logger.Errorw(ctx, "failed to close file", log.Fields{"error": err})
}
diff --git a/internal/pkg/swupg/file_download_manager.go b/internal/pkg/swupg/file_download_manager.go
index 05ffcf9..1893b4d 100755
--- a/internal/pkg/swupg/file_download_manager.go
+++ b/internal/pkg/swupg/file_download_manager.go
@@ -52,24 +52,24 @@
)
type downloadImageParams struct {
+ downloadContextCancelFn context.CancelFunc
downloadImageName string
downloadImageURL string
- downloadImageState FileState
downloadImageLen int64
+ downloadImageState FileState
downloadImageCRC uint32
downloadActive bool
- downloadContextCancelFn context.CancelFunc
}
type requesterChannelMap map[chan<- bool]struct{} //using an empty structure map for easier (unique) element appending
// FileDownloadManager structure holds information needed for downloading to and storing images within the adapter
type FileDownloadManager struct {
+ dnldImgReadyWaiting map[string]requesterChannelMap
+ downloadImageDscSlice []downloadImageParams
+ dlToAdapterTimeout time.Duration
mutexFileState sync.RWMutex
mutexDownloadImageDsc sync.RWMutex
- downloadImageDscSlice []downloadImageParams
- dnldImgReadyWaiting map[string]requesterChannelMap
- dlToAdapterTimeout time.Duration
}
// NewFileDownloadManager constructor returns a new instance of a FileDownloadManager
@@ -163,7 +163,7 @@
return nil, err
}
defer func() {
- err := file.Close()
+ err = file.Close()
if err != nil {
logger.Errorw(ctx, "failed to close file", log.Fields{"error": err})
}
@@ -376,13 +376,14 @@
//trying to download - do it in background as it may take some time ...
go func() {
+ var cancel context.CancelFunc
req, err2 := http.NewRequest("GET", urlBase.String(), nil)
if err2 != nil {
logger.Errorw(ctx, "could not generate http request", log.Fields{"url": urlBase.String(), "error": err2})
dm.removeImage(ctx, aFileName, false) //wo FileSystem access
return
}
- ctx, cancel := context.WithDeadline(ctx, time.Now().Add(dm.dlToAdapterTimeout)) //timeout as given from SetDownloadTimeout()
+ ctx, cancel = context.WithDeadline(ctx, time.Now().Add(dm.dlToAdapterTimeout)) //timeout as given from SetDownloadTimeout()
dm.updateDownloadCancel(ctx, aFileName, cancel)
defer cancel()
_ = req.WithContext(ctx)
@@ -406,7 +407,7 @@
}()
// Create the file
- aLocalPathName := aFilePath + "/" + aFileName
+ aLocalPathName := filepath.Clean(filepath.Join(aFilePath, aFileName))
file, err := os.Create(aLocalPathName)
if err != nil {
logger.Errorw(ctx, "could not create local file", log.Fields{"path_file": aLocalPathName, "error": err})
diff --git a/internal/pkg/swupg/omci_onu_upgrade.go b/internal/pkg/swupg/omci_onu_upgrade.go
index 3da4913..5c54762 100755
--- a/internal/pkg/swupg/omci_onu_upgrade.go
+++ b/internal/pkg/swupg/omci_onu_upgrade.go
@@ -140,58 +140,58 @@
// OnuUpgradeFsm defines the structure for the state machine to config the PON ANI ports of ONU UNI ports via OMCI
type OnuUpgradeFsm struct {
pDeviceHandler cmn.IdeviceHandler
+ pDevEntry cmn.IonuDeviceEntry
pDownloadManager *AdapterDownloadManager
pFileManager *FileDownloadManager //used from R2.8 with new API version
- deviceID string
- pDevEntry cmn.IonuDeviceEntry
pOmciCC *cmn.OmciCC
pOnuDB *devdb.OnuDeviceDB
- requestEvent cmn.OnuDeviceEvent
//omciMIdsResponseReceived chan bool //seperate channel needed for checking multiInstance OMCI message responses
PAdaptFsm *cmn.AdapterFsm
pImageDsc *voltha.ImageDownload
- imageBuffer []byte
- origImageLength uint32 //as also limited by OMCI
- imageCRC uint32 //as per OMCI - ITU I.363.5 crc
- imageLength uint32 //including last bytes padding
- omciDownloadWindowSizeLimit uint8 //windowSize-1 in sections
- omciDownloadWindowSizeLast uint8 //number of sections in last window
- noOfSections uint32 //uint32 range for sections should be sufficient for very long images
- nextDownloadSectionsAbsolute uint32 //number of next section to download in overall image
- nextDownloadSectionsWindow uint8 //number of next section to download within current window
- noOfWindows uint32 //uint32 range for windows should be sufficient for very long images
- nextDownloadWindow uint32 //number of next window to download
- InactiveImageMeID uint16 //ME-ID of the inactive image
- downloadToOnuTimeout4MB time.Duration //timeout for downloading the image to the ONU for a 4MB image slice
- omciSectionInterleaveDelay time.Duration //DownloadSectionInterleave delay in milliseconds
- delayEndSwDl bool //flag to provide a delay between last section and EndSwDl
- repeatAbort bool //flag to indicate if OMCI EndSwDownload (abort) is to be repeated
pLastTxMeInstance *me.ManagedEntity
- waitCountEndSwDl uint8 //number, how often is waited for EndSwDl at maximum
- waitDelayEndSwDl time.Duration //duration, how long is waited before next request on EndSwDl
chReceiveExpectedResponse chan bool
- useAPIVersion43 bool //flag for indication on which API version is used (and accordingly which specific methods)
- mutexUpgradeParams sync.RWMutex //mutex to protect members for parallel function requests and omci response processing
- imageVersion string //name of the image as used within OMCI (and on extrenal API interface)
- imageIdentifier string //name of the image as used in the adapter
- mutexIsAwaitingAdapterDlResponse sync.RWMutex
chAdapterDlReady chan bool
chAbortDelayEndSwDl chan struct{}
- isWaitingForAdapterDlResponse bool
chOnuDlReady chan bool
- activateImage bool
- commitImage bool
+ chReceiveAbortEndSwDlResponse chan tEndSwDlResponseResult
+ deviceID string
+ imageVersion string //name of the image as used within OMCI (and on extrenal API interface)
+ imageIdentifier string //name of the image as used in the adapter
+ imageBuffer []byte
+ requestEvent cmn.OnuDeviceEvent
+ downloadToOnuTimeout4MB time.Duration //timeout for downloading the image to the ONU for a 4MB image slice
+ omciSectionInterleaveDelay time.Duration //DownloadSectionInterleave delay in milliseconds
+ waitDelayEndSwDl time.Duration //duration, how long is waited before next request on EndSwDl
+ omciDownloadSectionSize int64
+ mutexUpgradeParams sync.RWMutex //mutex to protect members for parallel function requests and omci response processing
+ mutexIsAwaitingAdapterDlResponse sync.RWMutex
mutexAbortRequest sync.RWMutex
+ origImageLength uint32 //as also limited by OMCI
+ imageCRC uint32 //as per OMCI - ITU I.363.5 crc
+ imageLength uint32 //including last bytes padding
+ noOfSections uint32 //uint32 range for sections should be sufficient for very long images
+ nextDownloadSectionsAbsolute uint32 //number of next section to download in overall image
+ noOfWindows uint32 //uint32 range for windows should be sufficient for very long images
+ nextDownloadWindow uint32 //number of next window to download
abortRequested voltha.ImageState_ImageFailureReason
- conditionalCancelRequested bool
- upgradePhase tUpgradePhase
volthaDownloadState voltha.ImageState_ImageDownloadState
volthaDownloadReason voltha.ImageState_ImageFailureReason
volthaImageState voltha.ImageState_ImageActivationState
+ InactiveImageMeID uint16 //ME-ID of the inactive image
+ omciDownloadWindowSizeLimit uint8 //windowSize-1 in sections
+ omciDownloadWindowSizeLast uint8 //number of sections in last window
+ nextDownloadSectionsWindow uint8 //number of next section to download within current window
+ delayEndSwDl bool //flag to provide a delay between last section and EndSwDl
+ repeatAbort bool //flag to indicate if OMCI EndSwDownload (abort) is to be repeated
+ waitCountEndSwDl uint8 //number, how often is waited for EndSwDl at maximum
+ useAPIVersion43 bool //flag for indication on which API version is used (and accordingly which specific methods)
+ isWaitingForAdapterDlResponse bool
+ activateImage bool
+ commitImage bool
+ conditionalCancelRequested bool
+ upgradePhase tUpgradePhase
isEndSwDlOpen bool
- chReceiveAbortEndSwDlResponse chan tEndSwDlResponseResult
isExtendedOmci bool
- omciDownloadSectionSize int64
}
// NewOnuUpgradeFsm is the 'constructor' for the state machine to config the PON ANI ports
@@ -341,7 +341,7 @@
}
logger.Errorw(ctx, "OnuUpgradeFsm abort: invalid FSM base pointer or state", log.Fields{
"device-id": oFsm.deviceID})
- return fmt.Errorf(fmt.Sprintf("OnuUpgradeFsm abort: invalid FSM base pointer or state for device-id: %s", oFsm.deviceID))
+ return fmt.Errorf("OnuUpgradeFsm abort: invalid FSM base pointer or state for device-id: %s", oFsm.deviceID)
}
// SetDownloadParamsAfterDownload configures the needed parameters for a specific download to the ONU according to
@@ -374,7 +374,7 @@
oFsm.mutexUpgradeParams.Unlock()
logger.Errorw(ctx, "OnuUpgradeFsm abort: invalid FSM base pointer or state", log.Fields{
"device-id": oFsm.deviceID})
- return fmt.Errorf(fmt.Sprintf("OnuUpgradeFsm abort: invalid FSM base pointer or state for device-id: %s", oFsm.deviceID))
+ return fmt.Errorf("OnuUpgradeFsm abort: invalid FSM base pointer or state for device-id: %s", oFsm.deviceID)
}
// SetActivationParamsRunning sets the activate and commit flags for a running download to the ONU according to adapters rpc call
@@ -391,8 +391,8 @@
logger.Errorw(ctx, "OnuUpgradeFsm abort: mismatching upgrade image", log.Fields{
"device-id": oFsm.deviceID, "request-image": aImageIdentifier, "fsm-image": oFsm.imageIdentifier})
oFsm.mutexUpgradeParams.Unlock()
- return fmt.Errorf(fmt.Sprintf("OnuUpgradeFsm params ignored: requested image-name not used in current upgrade for device-id: %s",
- oFsm.deviceID))
+ return fmt.Errorf("OnuUpgradeFsm params ignored: requested image-name not used in current upgrade for device-id: %s",
+ oFsm.deviceID)
}
oFsm.activateImage = true
oFsm.commitImage = aCommit
@@ -413,7 +413,7 @@
}
logger.Errorw(ctx, "OnuUpgradeFsm abort: invalid FSM base pointer", log.Fields{
"device-id": oFsm.deviceID})
- return fmt.Errorf(fmt.Sprintf("OnuUpgradeFsm abort: invalid FSM base pointer for device-id: %s", oFsm.deviceID))
+ return fmt.Errorf("OnuUpgradeFsm abort: invalid FSM base pointer for device-id: %s", oFsm.deviceID)
}
// SetActivationParamsStart starts upgrade processing with immediate activation
@@ -443,7 +443,7 @@
oFsm.mutexUpgradeParams.Unlock()
logger.Errorw(ctx, "OnuUpgradeFsm abort: invalid FSM base pointer or state", log.Fields{
"device-id": oFsm.deviceID})
- return fmt.Errorf(fmt.Sprintf("OnuUpgradeFsm abort: invalid FSM base pointer or state for device-id: %s", oFsm.deviceID))
+ return fmt.Errorf("OnuUpgradeFsm abort: invalid FSM base pointer or state for device-id: %s", oFsm.deviceID)
}
// SetCommitmentParamsRunning sets the commit flag for a running download to the ONU according to adapters rpc call
@@ -461,8 +461,8 @@
"device-id": oFsm.deviceID, "request-identifier": aImageIdentifier, "fsm-identifier": oFsm.imageIdentifier,
"request-version": aImageVersion, "fsm-version": oFsm.imageVersion})
oFsm.mutexUpgradeParams.Unlock()
- return fmt.Errorf(fmt.Sprintf("OnuUpgradeFsm params ignored: requested image-name not used in current upgrade for device-id: %s",
- oFsm.deviceID))
+ return fmt.Errorf("OnuUpgradeFsm params ignored: requested image-name not used in current upgrade for device-id: %s",
+ oFsm.deviceID)
}
oFsm.commitImage = true
oFsm.mutexUpgradeParams.Unlock()
@@ -480,7 +480,7 @@
//should never occur
logger.Errorw(ctx, "OnuUpgradeFsm abort: invalid FSM base pointer", log.Fields{
"device-id": oFsm.deviceID})
- return fmt.Errorf(fmt.Sprintf("OnuUpgradeFsm abort: invalid FSM base pointer for device-id: %s", oFsm.deviceID))
+ return fmt.Errorf("OnuUpgradeFsm abort: invalid FSM base pointer for device-id: %s", oFsm.deviceID)
}
// SetCommitmentParamsStart starts upgrade processing with immediate commitment
@@ -508,7 +508,7 @@
oFsm.mutexUpgradeParams.Unlock()
logger.Errorw(ctx, "OnuUpgradeFsm abort: invalid FSM base pointer or state", log.Fields{
"device-id": oFsm.deviceID})
- return fmt.Errorf(fmt.Sprintf("OnuUpgradeFsm abort: invalid FSM base pointer or state for device-id: %s", oFsm.deviceID))
+ return fmt.Errorf("OnuUpgradeFsm abort: invalid FSM base pointer or state for device-id: %s", oFsm.deviceID)
}
// GetCommitFlag delivers the commit flag that was configured here
@@ -733,6 +733,7 @@
oFsm.isEndSwDlOpen = true
}
+//nolint:unparam
func (oFsm *OnuUpgradeFsm) enterDownloadSection(ctx context.Context, e *fsm.Event) {
logger.Debugw(ctx, "OnuUpgradeFsm start downloading sections", log.Fields{
"device-id": oFsm.deviceID, "absolute window": oFsm.nextDownloadWindow})
@@ -866,12 +867,13 @@
}
}
} //runSwDlSectionWindow
-
+//nolint:unparam
func (oFsm *OnuUpgradeFsm) enterVerifyWindow(ctx context.Context, e *fsm.Event) {
logger.Debugw(ctx, "OnuUpgradeFsm verify DL window ack", log.Fields{
"for window": oFsm.nextDownloadWindow, "device-id": oFsm.deviceID})
}
+//nolint:unparam
func (oFsm *OnuUpgradeFsm) enterFinalizeDL(ctx context.Context, e *fsm.Event) {
logger.Infow(ctx, "OnuUpgradeFsm finalize DL", log.Fields{
"device-id": oFsm.deviceID, "crc": strconv.FormatInt(int64(oFsm.imageCRC), 16), "delay": oFsm.delayEndSwDl})
@@ -931,6 +933,7 @@
_ = pBaseFsm.PFsm.Event(UpgradeEvWaitEndDownload)
} //delayAndSendEndSwDl
+//nolint:unparam
func (oFsm *OnuUpgradeFsm) enterWaitEndDL(ctx context.Context, e *fsm.Event) {
logger.Infow(ctx, "OnuUpgradeFsm WaitEndDl", log.Fields{
"device-id": oFsm.deviceID, "wait delay": oFsm.waitDelayEndSwDl * time.Second, "wait count": oFsm.waitCountEndSwDl})
@@ -1008,6 +1011,7 @@
}
}
+//nolint:unparam
func (oFsm *OnuUpgradeFsm) enterCheckImageName(ctx context.Context, e *fsm.Event) {
logger.Debugw(ctx, "OnuUpgradeFsm checking downloaded image name", log.Fields{
"device-id": oFsm.deviceID, "me-id": oFsm.InactiveImageMeID})
@@ -1024,6 +1028,7 @@
oFsm.pLastTxMeInstance = meInstance
}
+//nolint:unparam
func (oFsm *OnuUpgradeFsm) enterActivateSw(ctx context.Context, e *fsm.Event) {
logger.Infow(ctx, "OnuUpgradeFsm activate SW", log.Fields{
"device-id": oFsm.deviceID, "me-id": oFsm.InactiveImageMeID})
@@ -1042,6 +1047,7 @@
oFsm.mutexUpgradeParams.Unlock()
}
+//nolint:unparam
func (oFsm *OnuUpgradeFsm) enterCommitSw(ctx context.Context, e *fsm.Event) {
logger.Debugw(ctx, "OnuUpgradeFsm start commit SW", log.Fields{
"device-id": oFsm.deviceID, "me-id": oFsm.InactiveImageMeID})
@@ -1086,6 +1092,7 @@
}(pBaseFsm)
}
+//nolint:unparam
func (oFsm *OnuUpgradeFsm) enterCheckCommitted(ctx context.Context, e *fsm.Event) {
logger.Debugw(ctx, "OnuUpgradeFsm checking committed SW", log.Fields{
"device-id": oFsm.deviceID, "me-id": oFsm.InactiveImageMeID})
@@ -1102,6 +1109,7 @@
oFsm.pLastTxMeInstance = meInstance
}
+//nolint:unparam
func (oFsm *OnuUpgradeFsm) enterResetting(ctx context.Context, e *fsm.Event) {
logger.Debugw(ctx, "OnuUpgradeFsm resetting", log.Fields{"device-id": oFsm.deviceID})
@@ -1143,6 +1151,7 @@
}
}
+//nolint:unparam
func (oFsm *OnuUpgradeFsm) enterAbortingDL(ctx context.Context, e *fsm.Event) {
logger.Debugw(ctx, "OnuUpgradeFsm aborting download to ONU", log.Fields{"device-id": oFsm.deviceID})
@@ -1218,6 +1227,7 @@
return false
}
+//nolint:unparam
func (oFsm *OnuUpgradeFsm) enterRestarting(ctx context.Context, e *fsm.Event) {
logger.Debugw(ctx, "OnuUpgradeFsm restarting", log.Fields{"device-id": oFsm.deviceID})
pConfigUpgradeStateAFsm := oFsm.PAdaptFsm
@@ -1241,6 +1251,7 @@
}
}
+//nolint:unparam
func (oFsm *OnuUpgradeFsm) enterDisabled(ctx context.Context, e *fsm.Event) {
logger.Debugw(ctx, "OnuUpgradeFsm enters disabled state", log.Fields{"device-id": oFsm.deviceID})
// no need to flush possible channels here, Upgrade FSM will be completely removed, garbage collector should find its way
@@ -1959,6 +1970,8 @@
}
// stateUpdateOnReset writes the download and/or image state on entering the reset state according to FSM internal indications
+//
+//nolint:unparam
func (oFsm *OnuUpgradeFsm) stateUpdateOnReset(ctx context.Context) {
oFsm.mutexUpgradeParams.Lock()
defer oFsm.mutexUpgradeParams.Unlock()
diff --git a/internal/pkg/swupg/onu_image_status.go b/internal/pkg/swupg/onu_image_status.go
index 4423e2c..e432c58 100755
--- a/internal/pkg/swupg/onu_image_status.go
+++ b/internal/pkg/swupg/onu_image_status.go
@@ -33,16 +33,16 @@
// OnuImageStatus implements methods to get status info of onu images
type OnuImageStatus struct {
- deviceID string
pDeviceHandler cmn.IdeviceHandler
pDevEntry cmn.IonuDeviceEntry
pOmciCC *cmn.OmciCC
requestedAttributes me.AttributeValueMap
- mutexWaitingForResp sync.RWMutex
- waitingForResp bool
respChannel chan cmn.Message
- mutexPLastTxMeInstance sync.RWMutex
pLastTxMeInstance *me.ManagedEntity
+ deviceID string
+ mutexWaitingForResp sync.RWMutex
+ mutexPLastTxMeInstance sync.RWMutex
+ waitingForResp bool
isExtendedOmci bool
}