UPSTREAM: <drop>: increase loglevel for health check
@@ -22,9 +22,11 @@ import (
"net/http"
"strings"
"sync"
+ "sync/atomic"
"time"
"github.com/golang/glog"
+ "k8s.io/apimachinery/pkg/util/wait"
)
// HealthzChecker is a named healthz checker.
@@ -58,26 +60,31 @@ func (ping) Check(_ *http.Request) error {
}
// LogHealthz returns true if logging is not blocked
-var LogHealthz HealthzChecker = log{}
+var LogHealthz HealthzChecker = &log{}
-type log struct{}
+type log struct {
+ startOnce sync.Once
+ lastVerified atomic.Value
+}
-func (log) Name() string {
+func (*log) Name() string {
return "log"
}
-func (log) Check(_ *http.Request) error {
- done := make(chan struct{})
- go func() {
- glog.Info("/healthz/log check")
- close(done)
- }()
- select {
- case <-done:
+func (l *log) Check(_ *http.Request) error {
+ l.startOnce.Do(func() {
+ l.lastVerified.Store(time.Now())
+ go wait.Forever(func() {
+ glog.Flush()
+ l.lastVerified.Store(time.Now())
+ }, time.Minute)
+ })
+
+ lastVerified := l.lastVerified.Load().(time.Time)
+ if time.Since(lastVerified) < (2 * time.Minute) {
return nil
- case <-time.After(time.Second):
- return fmt.Errorf("logging blocked")
}
+ return fmt.Errorf("logging blocked")
}
// NamedCheck returns a healthz checker for the given name and function.
