diff --git a/app/controllers/health_controller.go b/app/controllers/health_controller.go index 7b0c11fd..059dfdf3 100644 --- a/app/controllers/health_controller.go +++ b/app/controllers/health_controller.go @@ -84,7 +84,7 @@ func (hc *HealthController) CheckHealth() bool { } func (hc *HealthController) Run(healthChan <-chan *ControllerHeartbeat, stopCh <-chan struct{}, wg *sync.WaitGroup) error { - t := time.NewTicker(3 * time.Second) + t := time.NewTicker(1.5 * time.Second) defer wg.Done() glog.Info("Starting health controller") @@ -114,7 +114,7 @@ func (hc *HealthController) Run(healthChan <-chan *ControllerHeartbeat, stopCh < case heartbeat := <-healthChan: hc.HandleHeartbeat(heartbeat) case <-t.C: - glog.Info("Health controller tick") + glog.V(4).Info("Health controller tick") } } diff --git a/app/controllers/metrics_controller.go b/app/controllers/metrics_controller.go index a52f8b63..51c1a30d 100644 --- a/app/controllers/metrics_controller.go +++ b/app/controllers/metrics_controller.go @@ -5,6 +5,7 @@ import ( "net/http" "strconv" "sync" + "time" "github.com/cloudnativelabs/kube-router/app/options" "github.com/golang/glog" @@ -119,6 +120,7 @@ type MetricsController struct { // Run prometheus metrics controller func (mc *MetricsController) Run(healthChan chan<- *ControllerHeartbeat, stopCh <-chan struct{}, wg *sync.WaitGroup) error { + t := time.NewTicker(3 * time.Second) defer wg.Done() glog.Info("Starting metrics controller") @@ -136,15 +138,21 @@ func (mc *MetricsController) Run(healthChan chan<- *ControllerHeartbeat, stopCh glog.Errorf("Metrics controller error: %s", err) } }() - - sendHeartBeat(healthChan, "MC") - - <-stopCh - glog.Infof("Shutting down metrics controller") - if err := srv.Shutdown(context.Background()); err != nil { - glog.Errorf("could not shutdown: %v", err) + for { + sendHeartBeat(healthChan, "MC") + select { + case <-stopCh: + glog.Infof("Shutting down metrics controller") + if err := srv.Shutdown(context.Background()); err != nil { + glog.Errorf("could not shutdown: %v", err) + } + return nil + case <-t.C: + glog.V(4).Info("Metrics controller tick") } - return nil + + + } // NewMetricsController returns new MetricController object diff --git a/app/server.go b/app/server.go index 2affe16b..a6a150dd 100644 --- a/app/server.go +++ b/app/server.go @@ -141,7 +141,7 @@ func (kr *KubeRouter) Run() error { return errors.New("Failed to create metrics controller: " + err.Error()) } wg.Add(1) - go mc.Run(stopCh, &wg) + go mc.Run(healthChan, stopCh, &wg) } else if kr.Config.MetricsPort > 65535 { glog.Errorf("Metrics port must be over 0 and under 65535, given port: %d", kr.Config.MetricsPort)