[VOL-5445] Fix for ONU adapter stuck in Not ready state when registering with rwcore
Change-Id: Ibfa0581c47a6714f9905efe532fb19eb38de1922
Signed-off-by: bseeniva <balaji.seenivasan@radisys.com>
diff --git a/VERSION b/VERSION
index e8b6c77..8b7b0b5 100644
--- a/VERSION
+++ b/VERSION
@@ -1 +1 @@
-3.6.11
+3.6.12
diff --git a/rw_core/core/device/agent.go b/rw_core/core/device/agent.go
index 49f2b72..6755a5f 100755
--- a/rw_core/core/device/agent.go
+++ b/rw_core/core/device/agent.go
@@ -1364,7 +1364,7 @@
func (agent *Agent) stopReconcile() {
agent.stopReconcilingMutex.Lock()
if agent.stopReconciling != nil {
- agent.stopReconciling <- 0
+ close(agent.stopReconciling)
}
agent.stopReconcilingMutex.Unlock()
}
@@ -1381,6 +1381,9 @@
// If any reconciling is in progress just abort it. The adapter is gone.
agent.stopReconcile()
+ agent.stopReconcilingMutex.Lock()
+ agent.stopReconciling = nil
+ agent.stopReconcilingMutex.Unlock()
logger.Infow(ctx, "aborting-current-running-requests-after-sendstop", log.Fields{"device-id": agent.deviceID})
@@ -1654,6 +1657,16 @@
agent.logDeviceUpdate(ctx, nil, nil, requestStatus, reconcileErr, desc)
break retry
}
+ case _, ok := <-agent.stopReconciling:
+ // This case is executed when the reconciling request is either not sent to the adapter
+ // or fails in the adapter, and the reconciling aborted by the abortAllProcessing function.
+ if !ok {
+ logger.Warnw(ctx, "Stop Reconciling channel closed", log.Fields{"device-id": agent.deviceID})
+ err := fmt.Errorf("reconciling channel closed:%w", errReconcileAborted)
+ desc = "reconciling-channel-closed"
+ agent.logDeviceUpdate(ctx, nil, nil, requestStatus, err, desc)
+ }
+ break retry
}
}
// Success
@@ -1713,9 +1726,6 @@
// if reconciling need to be stopped
case _, ok := <-agent.stopReconciling:
- agent.stopReconcilingMutex.Lock()
- agent.stopReconciling = nil
- agent.stopReconcilingMutex.Unlock()
if !ok {
// channel-closed
return fmt.Errorf("reconcile channel closed:%w", errReconcileAborted)
@@ -1723,6 +1733,9 @@
return fmt.Errorf("reconciling aborted:%w", errReconcileAborted)
// Context expired
case <-ctx.Done():
+ agent.stopReconcilingMutex.Lock()
+ agent.stopReconciling = nil
+ agent.stopReconcilingMutex.Unlock()
return fmt.Errorf("context expired:%s :%w", ctx.Err(), errContextExpired)
}
}
@@ -1739,6 +1752,9 @@
}
defer agent.requestQueue.RequestComplete()
agent.stopReconcile()
+ agent.stopReconcilingMutex.Lock()
+ agent.stopReconciling = nil
+ agent.stopReconcilingMutex.Unlock()
err = agent.updateTransientState(ctx, core.DeviceTransientState_NONE)
if err != nil {
logger.Errorf(ctx, "transient-state-update-failed", log.Fields{"error": err})