VOL-4774:openonuAdapterGo: Panic during scale test
Change-Id: Ie41689194d944d533e118a24297b0a9685ade717
diff --git a/internal/pkg/core/device_handler.go b/internal/pkg/core/device_handler.go
index b9cadf0..7f3febf 100755
--- a/internal/pkg/core/device_handler.go
+++ b/internal/pkg/core/device_handler.go
@@ -3750,7 +3750,10 @@
// reset like onu rebooted.
dh.pOnuMetricsMgr.InitializeMetricCollectionTime(ctx)
dh.setCollectorIsRunning(true)
+ statsCollectionticker := time.NewTicker((pmmgr.FrequencyGranularity) * time.Second)
+ defer statsCollectionticker.Stop()
for {
+
select {
case <-dh.stopCollector:
dh.setCollectorIsRunning(false)
@@ -3773,7 +3776,7 @@
}
return
- case <-time.After(time.Duration(pmmgr.FrequencyGranularity) * time.Second): // Check every FrequencyGranularity to see if it is time for collecting metrics
+ case <-statsCollectionticker.C: // Check every FrequencyGranularity to see if it is time for collecting metrics
if !dh.pmConfigs.FreqOverride { // If FreqOverride is false, then NextGlobalMetricCollectionTime applies
// If the current time is eqaul to or greater than the NextGlobalMetricCollectionTime, collect the group and standalone metrics
if time.Now().Equal(dh.pOnuMetricsMgr.NextGlobalMetricCollectionTime) || time.Now().After(dh.pOnuMetricsMgr.NextGlobalMetricCollectionTime) {