Update go dependencies
This commit is contained in:
parent
3c1a5c5fc2
commit
6c33bee8fd
620 changed files with 29782 additions and 15901 deletions
32
vendor/k8s.io/apiserver/pkg/server/healthz/healthz.go
generated
vendored
32
vendor/k8s.io/apiserver/pkg/server/healthz/healthz.go
generated
vendored
|
|
@ -22,8 +22,12 @@ import (
|
|||
"net/http"
|
||||
"strings"
|
||||
"sync"
|
||||
"sync/atomic"
|
||||
"time"
|
||||
|
||||
"github.com/golang/glog"
|
||||
|
||||
"k8s.io/apimachinery/pkg/util/wait"
|
||||
)
|
||||
|
||||
// HealthzChecker is a named healthz checker.
|
||||
|
|
@ -56,6 +60,34 @@ func (ping) Check(_ *http.Request) error {
|
|||
return nil
|
||||
}
|
||||
|
||||
// LogHealthz returns true if logging is not blocked
|
||||
var LogHealthz HealthzChecker = &log{}
|
||||
|
||||
type log struct {
|
||||
startOnce sync.Once
|
||||
lastVerified atomic.Value
|
||||
}
|
||||
|
||||
func (l *log) Name() string {
|
||||
return "log"
|
||||
}
|
||||
|
||||
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
|
||||
}
|
||||
return fmt.Errorf("logging blocked")
|
||||
}
|
||||
|
||||
// NamedCheck returns a healthz checker for the given name and function.
|
||||
func NamedCheck(name string, check func(r *http.Request) error) HealthzChecker {
|
||||
return &healthzCheck{name, check}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue