VOL-4197: Add uniport to OnuGemInfo cache in flow-manager module.
Otherwise, during cleanup the uni-ports are not detected and the
cleanup handler leaves out stale entries for the {pon,onu,uni}
tuple on kv store causing failures on new flow-adds due to
meter mismatch (from stale entries on etcd).

Change-Id: Ibacc053fd3435c3d8185b3f9b075861d21a2e4bc
diff --git a/internal/pkg/core/openolt_flowmgr.go b/internal/pkg/core/openolt_flowmgr.go
index 9c1cb09..978cea8 100644
--- a/internal/pkg/core/openolt_flowmgr.go
+++ b/internal/pkg/core/openolt_flowmgr.go
@@ -2149,6 +2149,24 @@
 	}
 
 	f.resourceMgr.AddUniPortToOnuInfo(ctx, intfID, onuID, portNo)
+	// also update flowmgr cache
+	f.onuGemInfoLock.Lock()
+	onugem, ok := f.onuGemInfoMap[onuID]
+	if ok {
+		found := false
+		for _, uni := range onugem.UniPorts {
+			if uni == portNo {
+				found = true
+				break
+			}
+		}
+		if !found {
+			onugem.UniPorts = append(onugem.UniPorts, portNo)
+			f.onuGemInfoMap[onuID] = onugem
+			logger.Infow(ctx, "added uni port to onugem cache", log.Fields{"uni": portNo})
+		}
+	}
+	f.onuGemInfoLock.Unlock()
 
 	TpID, err := getTpIDFromFlow(ctx, flow)
 	if err != nil {
@@ -2352,6 +2370,7 @@
 		f.onuGemInfoLock.Lock()
 		f.onuGemInfoMap[onuID] = onugem
 		f.onuGemInfoLock.Unlock()
+		logger.Debugw(ctx, "updated onu gem info from cache", log.Fields{"onugem": onugem})
 	} else {
 		logger.Warnw(ctx, "mismatched onu id", log.Fields{
 			"gem-port-id": gemPort,
@@ -3197,7 +3216,7 @@
 	return nil
 }
 
-func (f *OpenOltFlowMgr) getOnuGemInfoList() []rsrcMgr.OnuGemInfo {
+func (f *OpenOltFlowMgr) getOnuGemInfoList(ctx context.Context) []rsrcMgr.OnuGemInfo {
 	var onuGemInfoLst []rsrcMgr.OnuGemInfo
 	f.onuGemInfoLock.RLock()
 	defer f.onuGemInfoLock.RUnlock()