[VOL-3850] Support configuration of reconciling timeout via helm charts

Change-Id: Ic85e9ae01d87db8045f17ae2d5054bc16c2d0d4e
diff --git a/VERSION b/VERSION
index 815b2eb..e8ea05d 100755
--- a/VERSION
+++ b/VERSION
@@ -1 +1 @@
-1.2.4-dev166
+1.2.4
diff --git a/internal/pkg/config/config.go b/internal/pkg/config/config.go
index 628c689..8b657eb 100644
--- a/internal/pkg/config/config.go
+++ b/internal/pkg/config/config.go
@@ -54,6 +54,7 @@
 	defaultCurrentReplica             = 1
 	defaultTotalReplicas              = 1
 	defaultMaxTimeoutInterAdapterComm = 30 * time.Second
+	defaultMaxTimeoutReconciling      = 10 * time.Second
 	defaultOnuVendorIds               = "OPEN,ALCL,BRCM,TWSH,ALPH,ISKT,SFAA,BBSM,SCOM,ARPX,DACM,ERSN,HWTC,CIGG,ADTN,ARCA,AVMG"
 
 	// For Tracing
@@ -92,6 +93,7 @@
 	CurrentReplica              int
 	TotalReplicas               int
 	MaxTimeoutInterAdapterComm  time.Duration
+	MaxTimeoutReconciling       time.Duration
 	TraceEnabled                bool
 	TraceAgentAddress           string
 	LogCorrelationEnabled       bool
@@ -127,6 +129,7 @@
 		CurrentReplica:              defaultCurrentReplica,
 		TotalReplicas:               defaultTotalReplicas,
 		MaxTimeoutInterAdapterComm:  defaultMaxTimeoutInterAdapterComm,
+		MaxTimeoutReconciling:       defaultMaxTimeoutReconciling,
 		TraceEnabled:                defaultTraceEnabled,
 		TraceAgentAddress:           defaultTraceAgentAddress,
 		LogCorrelationEnabled:       defaultLogCorrelationEnabled,
@@ -210,6 +213,10 @@
 	flag.DurationVar(&(so.MaxTimeoutInterAdapterComm), "max_timeout_interadapter_comm",
 		defaultMaxTimeoutInterAdapterComm, help)
 
+	help = fmt.Sprintf("Maximum Number of seconds for the default ONU reconciling timeout")
+	flag.DurationVar(&(so.MaxTimeoutReconciling), "max_timeout_reconciling",
+		defaultMaxTimeoutReconciling, help)
+
 	help = fmt.Sprintf("Whether to send logs to tracing agent?")
 	flag.BoolVar(&(so.TraceEnabled), "trace_enabled", defaultTraceEnabled, help)
 
diff --git a/internal/pkg/onuadaptercore/device_handler.go b/internal/pkg/onuadaptercore/device_handler.go
index c452fe5..0f86675 100644
--- a/internal/pkg/onuadaptercore/device_handler.go
+++ b/internal/pkg/onuadaptercore/device_handler.go
@@ -91,9 +91,6 @@
 const (
 	cOnuActivatedEvent = "ONU_ACTIVATED"
 )
-const (
-	cReconcilingTimeout = 10 //seconds
-)
 
 type usedOmciConfigFsms int
 
@@ -2911,15 +2908,16 @@
 
 	}
 }
+
 func (dh *deviceHandler) startReconciling(ctx context.Context) {
-	logger.Debugw(ctx, "start reconciling", log.Fields{"device-id": dh.deviceID})
+	logger.Debugw(ctx, "start reconciling", log.Fields{"timeout": dh.pOpenOnuAc.maxTimeoutReconciling, "device-id": dh.deviceID})
 	if !dh.isReconciling() {
 		go func() {
 			select {
 			case <-dh.chReconcilingFinished:
 				logger.Debugw(ctx, "reconciling has been finished in time",
 					log.Fields{"device-id": dh.deviceID})
-			case <-time.After(time.Duration(cReconcilingTimeout) * time.Second):
+			case <-time.After(dh.pOpenOnuAc.maxTimeoutReconciling):
 				logger.Errorw(ctx, "timeout waiting for reconciling to be finished!",
 					log.Fields{"device-id": dh.deviceID})
 			}
diff --git a/internal/pkg/onuadaptercore/openonu.go b/internal/pkg/onuadaptercore/openonu.go
index f073282..b77276e 100644
--- a/internal/pkg/onuadaptercore/openonu.go
+++ b/internal/pkg/onuadaptercore/openonu.go
@@ -66,6 +66,7 @@
 	//GrpcTimeoutInterval         time.Duration
 	pSupportedFsms             *OmciDeviceFsms
 	maxTimeoutInterAdapterComm time.Duration
+	maxTimeoutReconciling      time.Duration
 	pDownloadManager           *adapterDownloadManager
 	metricsEnabled             bool
 	mibAuditInterval           time.Duration
@@ -97,6 +98,7 @@
 	openOnuAc.HeartbeatFailReportInterval = cfg.HeartbeatFailReportInterval
 	openOnuAc.AcceptIncrementalEvto = cfg.AccIncrEvto
 	openOnuAc.maxTimeoutInterAdapterComm = cfg.MaxTimeoutInterAdapterComm
+	openOnuAc.maxTimeoutReconciling = cfg.MaxTimeoutReconciling
 	//openOnuAc.GrpcTimeoutInterval = cfg.GrpcTimeoutInterval
 	openOnuAc.metricsEnabled = cfg.MetricsEnabled
 	openOnuAc.mibAuditInterval = cfg.MibAuditInterval