mirror of
https://github.com/cloudnativelabs/kube-router.git
synced 2025-10-10 09:21:04 +02:00
metrics controller ticker
This commit is contained in:
parent
12aec99844
commit
4f8f83d6eb
@ -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")
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -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)
|
||||
}
|
||||
}()
|
||||
|
||||
for {
|
||||
sendHeartBeat(healthChan, "MC")
|
||||
|
||||
<-stopCh
|
||||
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")
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
// NewMetricsController returns new MetricController object
|
||||
|
@ -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)
|
||||
|
Loading…
x
Reference in New Issue
Block a user