VOL-4965:Recover ONU on onu adapter restart when ONU during activation
Change-Id: I0c04625402ba197d4242faa1cc9c57f5577cacf1
diff --git a/internal/pkg/core/device_handler.go b/internal/pkg/core/device_handler.go
index 7f3febf..8a54933 100755
--- a/internal/pkg/core/device_handler.go
+++ b/internal/pkg/core/device_handler.go
@@ -338,6 +338,7 @@
logger.Debugw(ctx, "adopt_or_reconcile_device", log.Fields{"device-id": device.Id, "Address": device.GetHostAndPort()})
logger.Debugw(ctx, "Device FSM: ", log.Fields{"device-id": device.Id, "state": string(dh.pDeviceStateFsm.Current())})
+
if dh.pDeviceStateFsm.Is(devStNull) {
if err := dh.pDeviceStateFsm.Event(devEvDeviceInit); err != nil {
logger.Errorw(ctx, "Device FSM: Can't go to state DeviceInit", log.Fields{"device-id": device.Id, "err": err})
@@ -1971,6 +1972,7 @@
logger.Errorw(ctx, "No valid OnuDevice - aborting", log.Fields{"device-id": dh.DeviceID})
return fmt.Errorf("no valid OnuDevice: %s", dh.DeviceID)
}
+
if !dh.IsReconciling() {
if err := dh.StorePersistentData(ctx); err != nil {
logger.Warnw(ctx, "store persistent data error - continue as there will be additional write attempts",
@@ -1997,6 +1999,15 @@
logger.Debugw(ctx, "reconciling - uni-ports were not unlocked before adapter restart - resume with a normal start-up",
log.Fields{"device-id": dh.DeviceID})
dh.stopReconciling(ctx, true, cWaitReconcileFlowNoActivity)
+
+ //VOL-4965: Recover previously Activating ONU during reconciliation.
+ if dh.device.OperStatus == common.OperStatus_ACTIVATING {
+ logger.Debugw(ctx, "Reconciling an ONU in previously activating state, perform MIB reset and resume normal start up",
+ log.Fields{"device-id": dh.DeviceID})
+ pDevEntry.MutexPersOnuConfig.Lock()
+ pDevEntry.SOnuPersistentData.PersMibLastDbSync = 0
+ pDevEntry.MutexPersOnuConfig.Unlock()
+ }
} else {
pDevEntry.MutexPersOnuConfig.RUnlock()
}
@@ -2494,10 +2505,12 @@
log.Fields{"device-id": dh.DeviceID, "err": err})
}
} else {
- logger.Debugw(ctx, "reconciling - don't notify core that onu went to active but trigger tech profile config",
+ logger.Debugw(ctx, "reconciling - don't notify core that onu went to active but triggered tech profile config",
log.Fields{"device-id": dh.DeviceID})
dh.ReconcileDeviceTechProf(ctx)
+
// reconcilement will be continued after ani config is done
+
}
}