[VOL-5415] Reordered the stopping of heartbeat and readIndication routines in updateStateRebooted, moving it before the updateDeviceStateInCore function call
Signed-off-by: bseeniva <balaji.seenivasan@radisys.com>
Change-Id: Id25da143c3be57c89a116d2c8c00275a55d4bcc3
diff --git a/VERSION b/VERSION
index 00fc4bb..b586739 100644
--- a/VERSION
+++ b/VERSION
@@ -1 +1 @@
-4.5.7
+4.5.8
diff --git a/internal/pkg/core/device_handler.go b/internal/pkg/core/device_handler.go
index 98ea868..f6c3fa5 100755
--- a/internal/pkg/core/device_handler.go
+++ b/internal/pkg/core/device_handler.go
@@ -2984,14 +2984,8 @@
logger.Warnw(ctx, "update-state-rebooted", log.Fields{"device-id": dh.device.Id, "connect-status": device.ConnectStatus,
"admin-state": device.AdminState, "oper-status": device.OperStatus, "conn-status": voltha.ConnectStatus_UNREACHABLE})
- if err = dh.updateDeviceStateInCore(ctx, &ca.DeviceStateFilter{
- DeviceId: dh.device.Id,
- OperStatus: voltha.OperStatus_REBOOTED,
- ConnStatus: voltha.ConnectStatus_REACHABLE,
- }); err != nil {
- _ = olterrors.NewErrAdapter("device-state-update-failed", log.Fields{"device-id": dh.device.Id}, err).LogAt(log.ErrorLevel)
- }
-
+ // First, stop the read indication and heartbeat check routines to prevent any delay
+ // in cleanup, which could cause the heartbeat routine to restart the read indication.
dh.lockDevice.RLock()
// Stop the read indication only if it the routine is active
// The read indication would have already stopped due to failure on the gRPC stream following OLT going unreachable
@@ -3002,6 +2996,14 @@
}
dh.lockDevice.RUnlock()
+ if err = dh.updateDeviceStateInCore(ctx, &ca.DeviceStateFilter{
+ DeviceId: dh.device.Id,
+ OperStatus: voltha.OperStatus_REBOOTED,
+ ConnStatus: voltha.ConnectStatus_REACHABLE,
+ }); err != nil {
+ _ = olterrors.NewErrAdapter("device-state-update-failed", log.Fields{"device-id": dh.device.Id}, err).LogAt(log.ErrorLevel)
+ }
+
//raise olt communication failure event
raisedTs := time.Now().Unix()
cloned := proto.Clone(device).(*voltha.Device)