mirror of
https://github.com/cloudnativelabs/kube-router.git
synced 2025-10-08 16:31:07 +02:00
added startup delay before healthchecks starts
This commit is contained in:
parent
cf7c66ee7a
commit
f2da44590f
@ -117,6 +117,7 @@ func (hc *HealthController) CheckHealth() bool {
|
|||||||
|
|
||||||
//Run starts the HealthController
|
//Run starts the HealthController
|
||||||
func (hc *HealthController) Run(healthChan <-chan *ControllerHeartbeat, stopCh <-chan struct{}, wg *sync.WaitGroup) error {
|
func (hc *HealthController) Run(healthChan <-chan *ControllerHeartbeat, stopCh <-chan struct{}, wg *sync.WaitGroup) error {
|
||||||
|
Started := time.Now()
|
||||||
t := time.NewTicker(500 * time.Millisecond)
|
t := time.NewTicker(500 * time.Millisecond)
|
||||||
defer wg.Done()
|
defer wg.Done()
|
||||||
glog.Info("Starting health controller")
|
glog.Info("Starting health controller")
|
||||||
@ -138,9 +139,10 @@ func (hc *HealthController) Run(healthChan <-chan *ControllerHeartbeat, stopCh <
|
|||||||
hc.HTTPenabled = true
|
hc.HTTPenabled = true
|
||||||
}
|
}
|
||||||
for {
|
for {
|
||||||
|
//Give the controllers a few seconds to start before checking health
|
||||||
|
if time.Since(Started) > 5*time.Second {
|
||||||
hc.Status.Healthy = hc.CheckHealth()
|
hc.Status.Healthy = hc.CheckHealth()
|
||||||
|
}
|
||||||
select {
|
select {
|
||||||
case <-stopCh:
|
case <-stopCh:
|
||||||
glog.Infof("Shutting down health controller")
|
glog.Infof("Shutting down health controller")
|
||||||
@ -164,6 +166,9 @@ func NewHealthController(config *options.KubeRouterConfig) (*HealthController, e
|
|||||||
hc := HealthController{
|
hc := HealthController{
|
||||||
Config: config,
|
Config: config,
|
||||||
HealthPort: config.HealthPort,
|
HealthPort: config.HealthPort,
|
||||||
|
Status: HealthStats{
|
||||||
|
Healthy: false,
|
||||||
|
},
|
||||||
}
|
}
|
||||||
return &hc, nil
|
return &hc, nil
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user