[VOL-4633] openonuAdapterGo - multiple OLTs: reconcile for disabled ONU-devices in TT workflow fails sporadically
Change-Id: I3431d47847d4030f60697e69b7413e76d8ad97cf
diff --git a/internal/pkg/onuadaptercore/onu_device_entry.go b/internal/pkg/onuadaptercore/onu_device_entry.go
index 18bd1ef..2f6756c 100644
--- a/internal/pkg/onuadaptercore/onu_device_entry.go
+++ b/internal/pkg/onuadaptercore/onu_device_entry.go
@@ -278,6 +278,9 @@
mibTemplateKVStore *db.Backend
mutexPersOnuConfig sync.RWMutex
sOnuPersistentData onuPersistentData
+ reconcilingFlows bool
+ mutexReconcilingFlowsFlag sync.RWMutex
+ chReconcilingFlowsFinished chan bool //channel to indicate that reconciling of flows has been finished
mibTemplatePath string
mutexOnuKVStore sync.RWMutex
onuKVStore *db.Backend
@@ -326,6 +329,8 @@
onuDeviceEntry.devState = DeviceStatusInit
onuDeviceEntry.sOnuPersistentData.PersUniConfig = make([]uniPersConfig, 0)
onuDeviceEntry.sOnuPersistentData.PersTcontMap = make(map[uint16]uint16)
+ onuDeviceEntry.chReconcilingFlowsFinished = make(chan bool)
+ onuDeviceEntry.reconcilingFlows = false
onuDeviceEntry.chOnuKvProcessingStep = make(chan uint8)
onuDeviceEntry.omciRebootMessageReceivedChannel = make(chan Message, 2048)
//openomciagent.lockDeviceHandlersMap = sync.RWMutex{}
@@ -983,6 +988,34 @@
delete(oo.sOnuPersistentData.PersTcontMap, allocID)
}
+// setReconcilingFlows - TODO: add comment
+func (oo *OnuDeviceEntry) setReconcilingFlows(value bool) {
+ oo.mutexReconcilingFlowsFlag.Lock()
+ oo.reconcilingFlows = value
+ oo.mutexReconcilingFlowsFlag.Unlock()
+}
+
+// SendChReconcilingFlowsFinished - TODO: add comment
+func (oo *OnuDeviceEntry) SendChReconcilingFlowsFinished(ctx context.Context, value bool) {
+ if oo != nil { //if the object still exists (might have been already deleted in background)
+ //use asynchronous channel sending to avoid stucking on non-waiting receiver
+ select {
+ case oo.chReconcilingFlowsFinished <- value:
+ logger.Debugw(ctx, "reconciling - flows finished sent", log.Fields{"device-id": oo.deviceID})
+ default:
+ logger.Infow(ctx, "reconciling - flows finished not sent!", log.Fields{"device-id": oo.deviceID})
+ }
+ }
+}
+
+// isReconcilingFlows - TODO: add comment
+func (oo *OnuDeviceEntry) isReconcilingFlows() bool {
+ oo.mutexReconcilingFlowsFlag.RLock()
+ value := oo.reconcilingFlows
+ oo.mutexReconcilingFlowsFlag.RUnlock()
+ return value
+}
+
// PrepareForGarbageCollection - remove references to prepare for garbage collection
func (oo *OnuDeviceEntry) PrepareForGarbageCollection(ctx context.Context, aDeviceID string) {
logger.Debugw(ctx, "prepare for garbage collection", log.Fields{"device-id": aDeviceID})