Added configuration option to change the probe's listen address.
Change-Id: I7e8aa7bf4a4756f12211e7108cabcdc86aacd78a
diff --git a/common/probe/probe.go b/common/probe/probe.go
index fdb07e8..8a8e485 100644
--- a/common/probe/probe.go
+++ b/common/probe/probe.go
@@ -207,7 +207,7 @@
}
// ListenAndServe implements 3 HTTP endpoints on the given port for healthz, readz, and detailz. Returns only on error
-func (p *Probe) ListenAndServe(port int) {
+func (p *Probe) ListenAndServe(address string) {
mux := http.NewServeMux()
// Returns the result of the readyFunc calculation
@@ -219,7 +219,7 @@
// Returns the details of the services and their status as JSON
mux.HandleFunc("/detailz", p.detailzFunc)
s := &http.Server{
- Addr: fmt.Sprintf(":%d", port),
+ Addr: address,
Handler: mux,
}
log.Fatal(s.ListenAndServe())
diff --git a/ro_core/config/config.go b/ro_core/config/config.go
index be78228..28cde01 100644
--- a/ro_core/config/config.go
+++ b/ro_core/config/config.go
@@ -43,6 +43,7 @@
default_ROCoreCert = "pki/voltha.crt"
default_ROCoreCA = "pki/voltha-CA.pem"
default_Affinity_Router_Topic = "affinityRouter"
+ default_ProbeHost = ""
default_ProbePort = 8080
)
@@ -66,6 +67,7 @@
ROCoreCert string
ROCoreCA string
AffinityRouterTopic string
+ ProbeHost string
ProbePort int
}
@@ -93,6 +95,7 @@
ROCoreCert: default_ROCoreCert,
ROCoreCA: default_ROCoreCA,
AffinityRouterTopic: default_Affinity_Router_Topic,
+ ProbeHost: default_ProbeHost,
ProbePort: default_ProbePort,
}
return &roCoreFlag
@@ -142,6 +145,9 @@
help = fmt.Sprintf("Show version information and exit")
flag.BoolVar(&cf.DisplayVersionOnly, "version", default_DisplayVersionOnly, help)
+ help = fmt.Sprintf("The address on which to listen to answer liveness and readiness probe queries over HTTP.")
+ flag.StringVar(&(cf.ProbeHost), "probe_host", default_ProbeHost, help)
+
help = fmt.Sprintf("The port on which to listen to answer liveness and readiness probe queries over HTTP.")
flag.IntVar(&(cf.ProbePort), "probe_port", default_ProbePort, help)
diff --git a/ro_core/main.go b/ro_core/main.go
index 27ada02..a8508b8 100644
--- a/ro_core/main.go
+++ b/ro_core/main.go
@@ -241,7 +241,7 @@
* objects there can be a single probe end point for the process.
*/
p := &probe.Probe{}
- go p.ListenAndServe(ro.config.ProbePort)
+ go p.ListenAndServe(fmt.Sprintf("%s:%d", ro.config.ProbeHost, ro.config.ProbePort))
// Add the probe to the context to pass to all the services started
probeCtx := context.WithValue(ctx, probe.ProbeContextKey, p)
diff --git a/rw_core/config/config.go b/rw_core/config/config.go
index f9f1d3e..5f4a0e0 100644
--- a/rw_core/config/config.go
+++ b/rw_core/config/config.go
@@ -54,6 +54,7 @@
default_CorePairTopic = "rwcore_1"
default_MaxConnectionRetries = -1 // retries forever
default_ConnectionRetryInterval = 2 // in seconds
+ default_ProbeHost = ""
default_ProbePort = 8080
)
@@ -89,6 +90,7 @@
CorePairTopic string
MaxConnectionRetries int
ConnectionRetryInterval int
+ ProbeHost string
ProbePort int
}
@@ -128,6 +130,7 @@
CorePairTopic: default_CorePairTopic,
MaxConnectionRetries: default_MaxConnectionRetries,
ConnectionRetryInterval: default_ConnectionRetryInterval,
+ ProbeHost: default_ProbeHost,
ProbePort: default_ProbePort,
}
return &rwCoreFlag
@@ -216,6 +219,9 @@
help = fmt.Sprintf("The number of seconds between each connection retry attempt ")
flag.IntVar(&(cf.ConnectionRetryInterval), "connection_retry_interval", default_ConnectionRetryInterval, help)
+ help = fmt.Sprintf("The host on which to listen to answer liveness and readiness probe queries over HTTP.")
+ flag.StringVar(&(cf.ProbeHost), "probe_host", default_ProbeHost, help)
+
help = fmt.Sprintf("The port on which to listen to answer liveness and readiness probe queries over HTTP.")
flag.IntVar(&(cf.ProbePort), "probe_port", default_ProbePort, help)
diff --git a/rw_core/main.go b/rw_core/main.go
index 6f06576..2311029 100644
--- a/rw_core/main.go
+++ b/rw_core/main.go
@@ -276,7 +276,7 @@
* objects there can be a single probe end point for the process.
*/
p := &probe.Probe{}
- go p.ListenAndServe(rw.config.ProbePort)
+ go p.ListenAndServe(fmt.Sprintf("%s:%d", rw.config.ProbeHost, rw.config.ProbePort))
// Add the probe to the context to pass to all the services started
probeCtx := context.WithValue(ctx, probe.ProbeContextKey, p)