VOL-2101 kubernetes liveliness changes
Help text modified
Change-Id: Ia824436d6c9c06710930dfbca1528c6366e1ef64
diff --git a/config/config.go b/config/config.go
index ba93d87..d575231 100644
--- a/config/config.go
+++ b/config/config.go
@@ -1,17 +1,17 @@
 /*
- * Copyright 2018-present Open Networking Foundation
+* Copyright 2018-present Open Networking Foundation
 
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
 
- * http://www.apache.org/licenses/LICENSE-2.0
+* http://www.apache.org/licenses/LICENSE-2.0
 
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
  */
 
 //Package config provides the Log, kvstore, Kafka configuration
@@ -22,52 +22,57 @@
 	"fmt"
 	"github.com/opencord/voltha-lib-go/v2/pkg/log"
 	"os"
+	"time"
 )
 
 // Open OLT default constants
 const (
-	EtcdStoreName             = "etcd"
-	defaultInstanceid         = "openOlt001"
-	defaultKafkaadapterhost   = "127.0.0.1"
-	defaultKafkaadapterport   = 9092
-	defaultKafkaclusterhost   = "127.0.0.1"
-	defaultKafkaclusterport   = 9094
-	defaultKvstoretype        = EtcdStoreName
-	defaultKvstoretimeout     = 5 //in seconds
-	defaultKvstorehost        = "127.0.0.1"
-	defaultKvstoreport        = 2379 // Consul = 8500; Etcd = 2379
-	defaultLoglevel           = 0
-	defaultBanner             = false
-	defaultDisplayVersionOnly = false
-	defaultTopic              = "openolt"
-	defaultCoretopic          = "rwcore"
-	defaultEventtopic         = "voltha.events"
-	defaultOnunumber          = 1
-	defaultProbeHost          = ""
-	defaultProbePort          = 8080
+	EtcdStoreName               = "etcd"
+	defaultInstanceid           = "openOlt001"
+	defaultKafkaadapterhost     = "127.0.0.1"
+	defaultKafkaadapterport     = 9092
+	defaultKafkaclusterhost     = "127.0.0.1"
+	defaultKafkaclusterport     = 9094
+	defaultKvstoretype          = EtcdStoreName
+	defaultKvstoretimeout       = 5 //in seconds
+	defaultKvstorehost          = "127.0.0.1"
+	defaultKvstoreport          = 2379 // Consul = 8500; Etcd = 2379
+	defaultLoglevel             = 0
+	defaultBanner               = false
+	defaultDisplayVersionOnly   = false
+	defaultTopic                = "openolt"
+	defaultCoretopic            = "rwcore"
+	defaultEventtopic           = "voltha.events"
+	defaultOnunumber            = 1
+	defaultProbeHost            = ""
+	defaultProbePort            = 8080
+	defaultLiveProbeInterval    = 60 * time.Second
+	defaultNotLiveProbeInterval = 5 * time.Second // Probe more frequently when not alive
 )
 
 // AdapterFlags represents the set of configurations used by the read-write adaptercore service
 type AdapterFlags struct {
 	// Command line parameters
-	InstanceID         string
-	KafkaAdapterHost   string
-	KafkaAdapterPort   int
-	KafkaClusterHost   string
-	KafkaClusterPort   int
-	KVStoreType        string
-	KVStoreTimeout     int // in seconds
-	KVStoreHost        string
-	KVStorePort        int
-	Topic              string
-	CoreTopic          string
-	EventTopic         string
-	LogLevel           int
-	OnuNumber          int
-	Banner             bool
-	DisplayVersionOnly bool
-	ProbeHost          string
-	ProbePort          int
+	InstanceID           string
+	KafkaAdapterHost     string
+	KafkaAdapterPort     int
+	KafkaClusterHost     string
+	KafkaClusterPort     int
+	KVStoreType          string
+	KVStoreTimeout       int // in seconds
+	KVStoreHost          string
+	KVStorePort          int
+	Topic                string
+	CoreTopic            string
+	EventTopic           string
+	LogLevel             int
+	OnuNumber            int
+	Banner               bool
+	DisplayVersionOnly   bool
+	ProbeHost            string
+	ProbePort            int
+	LiveProbeInterval    time.Duration
+	NotLiveProbeInterval time.Duration
 }
 
 func init() {
@@ -77,24 +82,26 @@
 // NewAdapterFlags returns a new RWCore config
 func NewAdapterFlags() *AdapterFlags {
 	var adapterFlags = AdapterFlags{ // Default values
-		InstanceID:         defaultInstanceid,
-		KafkaAdapterHost:   defaultKafkaadapterhost,
-		KafkaAdapterPort:   defaultKafkaadapterport,
-		KafkaClusterHost:   defaultKafkaclusterhost,
-		KafkaClusterPort:   defaultKafkaclusterport,
-		KVStoreType:        defaultKvstoretype,
-		KVStoreTimeout:     defaultKvstoretimeout,
-		KVStoreHost:        defaultKvstorehost,
-		KVStorePort:        defaultKvstoreport,
-		Topic:              defaultTopic,
-		CoreTopic:          defaultCoretopic,
-		EventTopic:         defaultEventtopic,
-		LogLevel:           defaultLoglevel,
-		OnuNumber:          defaultOnunumber,
-		Banner:             defaultBanner,
-		DisplayVersionOnly: defaultDisplayVersionOnly,
-		ProbeHost:          defaultProbeHost,
-		ProbePort:          defaultProbePort,
+		InstanceID:           defaultInstanceid,
+		KafkaAdapterHost:     defaultKafkaadapterhost,
+		KafkaAdapterPort:     defaultKafkaadapterport,
+		KafkaClusterHost:     defaultKafkaclusterhost,
+		KafkaClusterPort:     defaultKafkaclusterport,
+		KVStoreType:          defaultKvstoretype,
+		KVStoreTimeout:       defaultKvstoretimeout,
+		KVStoreHost:          defaultKvstorehost,
+		KVStorePort:          defaultKvstoreport,
+		Topic:                defaultTopic,
+		CoreTopic:            defaultCoretopic,
+		EventTopic:           defaultEventtopic,
+		LogLevel:             defaultLoglevel,
+		OnuNumber:            defaultOnunumber,
+		Banner:               defaultBanner,
+		DisplayVersionOnly:   defaultDisplayVersionOnly,
+		ProbeHost:            defaultProbeHost,
+		ProbePort:            defaultProbePort,
+		LiveProbeInterval:    defaultLiveProbeInterval,
+		NotLiveProbeInterval: defaultNotLiveProbeInterval,
 	}
 	return &adapterFlags
 }
@@ -153,6 +160,12 @@
 	help = fmt.Sprintf("The port on which to listen to answer liveness and readiness probe queries over HTTP.")
 	flag.IntVar(&(so.ProbePort), "probe_port", defaultProbePort, help)
 
+	help = fmt.Sprintf("Number of seconds for the default liveliness check")
+	flag.DurationVar(&(so.LiveProbeInterval), "live_probe_interval", defaultLiveProbeInterval, help)
+
+	help = fmt.Sprintf("Number of seconds for liveliness check if probe is not running")
+	flag.DurationVar(&(so.NotLiveProbeInterval), "not_live_probe_interval", defaultNotLiveProbeInterval, help)
+
 	flag.Parse()
 
 	containerName := getContainerInfo()