PMs are missing because OMCI processor has not started before PM FSM.
Wait for OMCI processor in PM module to start before starting PM FSM.

Change-Id: I10707d8626f1c11f97946307fa7343dcab7b4fb5
diff --git a/VERSION b/VERSION
index d22daf7..c147335 100755
--- a/VERSION
+++ b/VERSION
@@ -1 +1 @@
-2.2.4-dev282
+2.2.4-dev283
diff --git a/internal/pkg/common/interfaces.go b/internal/pkg/common/interfaces.go
index 7317a35..25c8da7 100755
--- a/internal/pkg/common/interfaces.go
+++ b/internal/pkg/common/interfaces.go
@@ -19,6 +19,7 @@
 
 import (
 	"context"
+	"sync"
 	"time"
 
 	me "github.com/opencord/omci-lib-go/v2/generated"
@@ -66,7 +67,7 @@
 	ReasonUpdate(context.Context, uint8, bool) error
 
 	GetCollectorIsRunning() bool
-	StartCollector(context.Context)
+	StartCollector(context.Context, *sync.WaitGroup)
 	InitPmConfigs()
 	GetPmConfigs() *voltha.PmConfigs
 	GetMetricsEnabled() bool
diff --git a/internal/pkg/core/device_handler.go b/internal/pkg/core/device_handler.go
index 6465a0c..03b6ab3 100755
--- a/internal/pkg/core/device_handler.go
+++ b/internal/pkg/core/device_handler.go
@@ -2382,8 +2382,11 @@
 	_ = dh.ReasonUpdate(ctx, cmn.DrInitialMibDownloaded, !dh.IsReconciling() || dh.IsReconcilingReasonUpdate())
 
 	if !dh.GetCollectorIsRunning() {
+		var waitForOmciProcessor sync.WaitGroup
+		waitForOmciProcessor.Add(1)
 		// Start PM collector routine
-		go dh.StartCollector(ctx)
+		go dh.StartCollector(ctx, &waitForOmciProcessor)
+		waitForOmciProcessor.Wait()
 	}
 	if !dh.GetAlarmManagerIsRunning(ctx) {
 		go dh.StartAlarmManager(ctx)
@@ -3702,11 +3705,11 @@
 }
 
 // nolint: gocyclo
-func (dh *deviceHandler) StartCollector(ctx context.Context) {
+func (dh *deviceHandler) StartCollector(ctx context.Context, waitForOmciProcessor *sync.WaitGroup) {
 	logger.Debugw(ctx, "startingCollector", log.Fields{"device-id": dh.device.Id})
 
 	// Start routine to process OMCI GET Responses
-	go dh.pOnuMetricsMgr.ProcessOmciMessages(ctx)
+	go dh.pOnuMetricsMgr.ProcessOmciMessages(ctx, waitForOmciProcessor)
 	// Create Extended Frame PM ME
 	go dh.pOnuMetricsMgr.CreateEthernetFrameExtendedPMME(ctx)
 	// Initialize the next metric collection time.
diff --git a/internal/pkg/mib/mib_sync.go b/internal/pkg/mib/mib_sync.go
index dc1f35d..b5d1ff9 100755
--- a/internal/pkg/mib/mib_sync.go
+++ b/internal/pkg/mib/mib_sync.go
@@ -25,6 +25,7 @@
 	"fmt"
 	"strconv"
 	"strings"
+	"sync"
 
 	"github.com/looplab/fsm"
 
@@ -389,8 +390,11 @@
 		oo.baseDeviceHandler.SetReadyForOmciConfig(true)
 
 		if !oo.baseDeviceHandler.GetCollectorIsRunning() {
+			var waitForOmciProcess sync.WaitGroup
+			waitForOmciProcess.Add(1)
 			// Start PM collector routine
-			go oo.baseDeviceHandler.StartCollector(ctx)
+			go oo.baseDeviceHandler.StartCollector(ctx, &waitForOmciProcess)
+			waitForOmciProcess.Wait()
 		}
 		if !oo.baseDeviceHandler.GetAlarmManagerIsRunning(ctx) {
 			go oo.baseDeviceHandler.StartAlarmManager(ctx)
diff --git a/internal/pkg/pmmgr/onu_metrics_manager.go b/internal/pkg/pmmgr/onu_metrics_manager.go
index 25befe2..066339e 100755
--- a/internal/pkg/pmmgr/onu_metrics_manager.go
+++ b/internal/pkg/pmmgr/onu_metrics_manager.go
@@ -1031,7 +1031,7 @@
 }
 
 // ProcessOmciMessages - TODO: add comment
-func (mm *OnuMetricsManager) ProcessOmciMessages(ctx context.Context) {
+func (mm *OnuMetricsManager) ProcessOmciMessages(ctx context.Context, waitForOmciProcessor *sync.WaitGroup) {
 	logger.Infow(ctx, "Start routine to process OMCI-GET messages for device-id", log.Fields{"device-id": mm.deviceID})
 	// Flush metric collection channels to be safe.
 	// It is possible that there is stale data on this channel if the ProcessOmciMessages routine
@@ -1040,6 +1040,7 @@
 	// is stopped - as a result of ONU going down.
 	mm.flushMetricCollectionChannels(ctx)
 	mm.updateOmciProcessingStatus(true)
+	waitForOmciProcessor.Done()
 	for {
 		select {
 		case <-mm.StopProcessingOmciResponses: // stop this routine