[VOL-4067] : Fix mechanism used for closing PM collector, alarm manager
and self test handler module routines
Change-Id: Iec97d3a114191b15e00698b35da47555a9359935
diff --git a/VERSION b/VERSION
index 8e30f8d..2385672 100755
--- a/VERSION
+++ b/VERSION
@@ -1 +1 @@
-1.4.1-dev228
+1.4.1-dev229
diff --git a/internal/pkg/onuadaptercore/device_handler.go b/internal/pkg/onuadaptercore/device_handler.go
index 4330741..3dbaf48 100644
--- a/internal/pkg/onuadaptercore/device_handler.go
+++ b/internal/pkg/onuadaptercore/device_handler.go
@@ -2112,6 +2112,9 @@
if dh.getAlarmManagerIsRunning(ctx) {
dh.stopAlarmManager <- true
}
+ if dh.pSelfTestHdlr.GetSelfTestHandlerIsRunning() {
+ dh.pSelfTestHdlr.stopSelfTestModule <- true
+ }
//reset a possibly running upgrade FSM
// (note the Upgrade FSM may stay alive e.g. in state upgradeStWaitForCommit to endure the ONU reboot)
diff --git a/internal/pkg/onuadaptercore/omci_self_test_handler.go b/internal/pkg/onuadaptercore/omci_self_test_handler.go
index 2e968fb..ce82db8 100644
--- a/internal/pkg/onuadaptercore/omci_self_test_handler.go
+++ b/internal/pkg/onuadaptercore/omci_self_test_handler.go
@@ -64,7 +64,9 @@
selfTestFsmMap map[generated.ClassID]*fsmCb // The fsmCb is indexed by ME Class ID of the Test Action procedure
selfTestFsmLock sync.RWMutex
- stopSelfTestModule chan bool
+ selfTestHandlerLock sync.RWMutex
+ selfTestHandlerActive bool
+ stopSelfTestModule chan bool
}
// newSelfTestMsgHandlerCb creates the selfTestControlBlock
@@ -342,8 +344,9 @@
}
func (selfTestCb *selfTestControlBlock) waitForStopSelfTestModuleSignal(ctx context.Context) {
-
+ selfTestCb.SetSelfTestHandlerIsRunning(true)
<-selfTestCb.stopSelfTestModule // block on stop signal
+ selfTestCb.SetSelfTestHandlerIsRunning(false)
logger.Infow(ctx, "received stop signal - clean up start", log.Fields{"device-id": selfTestCb.deviceID})
selfTestCb.selfTestFsmLock.Lock()
@@ -363,6 +366,20 @@
//// Exported functions
+// SetSelfTestHandlerActive sets the value to selfTestCb.selfTestHandlerActive
+func (selfTestCb *selfTestControlBlock) SetSelfTestHandlerIsRunning(active bool) {
+ selfTestCb.selfTestHandlerLock.Lock()
+ defer selfTestCb.selfTestHandlerLock.Unlock()
+ selfTestCb.selfTestHandlerActive = active
+}
+
+// GetSelfTestHandlerActive gets selfTestCb.selfTestHandlerActive
+func (selfTestCb *selfTestControlBlock) GetSelfTestHandlerIsRunning() bool {
+ selfTestCb.selfTestHandlerLock.RLock()
+ defer selfTestCb.selfTestHandlerLock.RUnlock()
+ return selfTestCb.selfTestHandlerActive
+}
+
// selfTestRequest initiate Test Request handling procedure. The results are asynchronously conveyed on the respChan.
// If the return from selfTestRequest is NOT nil, the caller shall not wait for async response.
func (selfTestCb *selfTestControlBlock) SelfTestRequestStart(ctx context.Context, reqMsg extension.SingleGetValueRequest, commChan chan Message, respChan chan extension.SingleGetValueResponse) error {
diff --git a/internal/pkg/onuadaptercore/openonu.go b/internal/pkg/onuadaptercore/openonu.go
index babbda9..cfa2661 100644
--- a/internal/pkg/onuadaptercore/openonu.go
+++ b/internal/pkg/onuadaptercore/openonu.go
@@ -406,29 +406,29 @@
if err := handler.deleteDevicePersistencyData(ctx); err != nil {
errorsList = append(errorsList, err)
}
- select {
- case handler.stopCollector <- true: // stop the metric collector routine
+
+ // Stop PM, Alarm and Self Test event handler routines
+ if handler.getCollectorIsRunning() {
+ handler.stopCollector <- true
logger.Debugw(ctx, "sent stop signal to metric collector routine", log.Fields{"device-id": device.Id})
- default:
- logger.Warnw(ctx, "metric collector routine not waiting on stop signal", log.Fields{"device-id": device.Id})
+
}
- select {
- case handler.stopAlarmManager <- true: //stop the alarm manager.
+ if handler.getAlarmManagerIsRunning(ctx) {
+ handler.stopAlarmManager <- true
logger.Debugw(ctx, "sent stop signal to alarm manager", log.Fields{"device-id": device.Id})
- default:
- logger.Warnw(ctx, "alarm manager not waiting on stop signal", log.Fields{"device-id": device.Id})
}
+ if handler.pSelfTestHdlr.GetSelfTestHandlerIsRunning() {
+ handler.pSelfTestHdlr.stopSelfTestModule <- true
+ logger.Debugw(ctx, "sent stop signal to self test handler module", log.Fields{"device-id": device.Id})
+ }
+
+ // Clear PM data on the KV store
if handler.pOnuMetricsMgr != nil {
if err := handler.pOnuMetricsMgr.clearAllPmData(ctx); err != nil {
errorsList = append(errorsList, err)
}
}
- select {
- case handler.pSelfTestHdlr.stopSelfTestModule <- true:
- logger.Debugw(ctx, "sent stop signal to self test handler module", log.Fields{"device-id": device.Id})
- default:
- logger.Warnw(ctx, "self test handler module not waiting on stop signal", log.Fields{"device-id": device.Id})
- }
+
//don't leave any garbage - even in error case
oo.deleteDeviceHandlerToMap(handler)
if len(errorsList) > 0 {