[VOL-4469] Onu adapter reconcilement may stuck on VLAN processing, especially in TT traffic scenarios

Signed-off-by: mpagenko <michael.pagenkopf@adtran.com>
Change-Id: If321388c67e2e52eb04b8a55167eb3c1c7575e5d
diff --git a/internal/pkg/common/defines.go b/internal/pkg/common/defines.go
index e0e44db..d0135aa 100755
--- a/internal/pkg/common/defines.go
+++ b/internal/pkg/common/defines.go
@@ -19,6 +19,7 @@
 
 import (
 	"context"
+	"sync"
 	"time"
 
 	gp "github.com/google/gopacket"
@@ -337,3 +338,10 @@
 
 // CBasePathOnuKVStore - kv store path of ONU specific data
 const CBasePathOnuKVStore = "%s/openonu"
+
+///////////////////////////////////////////////////////////
+
+//WaitGroupWithTimeOut definitions to have waitGroup functionality with timeout
+type WaitGroupWithTimeOut struct {
+	sync.WaitGroup
+}
diff --git a/internal/pkg/common/interfaces.go b/internal/pkg/common/interfaces.go
index 54cbc18..c16f42f 100755
--- a/internal/pkg/common/interfaces.go
+++ b/internal/pkg/common/interfaces.go
@@ -89,12 +89,13 @@
 	StorePersUniFlowConfig(context.Context, uint8, *[]UniVlanFlowParams, bool) error
 
 	StartReconciling(context.Context, bool)
-	StopReconciling(context.Context, bool)
 	IsReconciling() bool
 	IsSkipOnuConfigReconciling() bool
 	PrepareReconcilingWithActiveAdapter(context.Context)
 	ReconcileDeviceTechProf(context.Context)
 	ReconcileDeviceFlowConfig(context.Context)
+	GetReconcileExpiryVlanConfigAbort() time.Duration
+	SendChUniVlanConfigFinished(value uint16)
 
 	VerifyUniVlanConfigRequest(context.Context, *OnuUniPort, uint8)
 	VerifyVlanConfigRequest(context.Context, uint8, uint8)
@@ -149,9 +150,6 @@
 
 	LockMutexPersOnuConfig()
 	UnlockMutexPersOnuConfig()
-
-	SetReconcilingFlows(bool)
-	SetChReconcilingFlowsFinished(bool)
 }
 
 // IonuMetricsManager interface to onuMetricsManager
diff --git a/internal/pkg/common/utils.go b/internal/pkg/common/utils.go
index e8a161c..3eb4121 100755
--- a/internal/pkg/common/utils.go
+++ b/internal/pkg/common/utils.go
@@ -27,6 +27,7 @@
 	"regexp"
 	"strconv"
 	"strings"
+	"time"
 
 	"github.com/looplab/fsm"
 	me "github.com/opencord/omci-lib-go/v2/generated"
@@ -161,3 +162,22 @@
 	}
 	return (VoipUniBaseEID + uniPortMacBpNo), nil
 }
+
+//WaitTimeout of waitGroupWithTimeOut is blocking
+//  returns true, if the wg request was executed successfully, false on timeout
+func (wg *WaitGroupWithTimeOut) WaitTimeout(timeout time.Duration) bool {
+	done := make(chan struct{})
+
+	go func() {
+		defer close(done)
+		wg.Wait()
+	}()
+
+	select {
+	case <-done:
+		return true
+
+	case <-time.After(timeout):
+		return false
+	}
+}