Add /readyz for kube-scheduler
/readyz contains `sched-handler-sync`, `leaderElection` (when election is enabled) and `shutdown` checks Kubernetes-commit: 44c08fdbd592b7c167ad0c3b0b4a3b52b99c116f
This commit is contained in:
parent
259cd1817c
commit
f59dd2d95e
|
|
@ -118,7 +118,7 @@ func (s *GenericAPIServer) AddLivezChecks(delay time.Duration, checks ...healthz
|
|||
// that we can register that the api-server is no longer ready while we attempt to gracefully
|
||||
// shutdown.
|
||||
func (s *GenericAPIServer) addReadyzShutdownCheck(stopCh <-chan struct{}) error {
|
||||
return s.AddReadyzChecks(shutdownCheck{stopCh})
|
||||
return s.AddReadyzChecks(healthz.NewShutdownHealthz(stopCh))
|
||||
}
|
||||
|
||||
// installHealthz creates the healthz endpoint for this server
|
||||
|
|
@ -139,25 +139,6 @@ func (s *GenericAPIServer) installLivez() {
|
|||
s.livezRegistry.installHandler(s.Handler.NonGoRestfulMux)
|
||||
}
|
||||
|
||||
// shutdownCheck fails if the embedded channel is closed. This is intended to allow for graceful shutdown sequences
|
||||
// for the apiserver.
|
||||
type shutdownCheck struct {
|
||||
StopCh <-chan struct{}
|
||||
}
|
||||
|
||||
func (shutdownCheck) Name() string {
|
||||
return "shutdown"
|
||||
}
|
||||
|
||||
func (c shutdownCheck) Check(req *http.Request) error {
|
||||
select {
|
||||
case <-c.StopCh:
|
||||
return fmt.Errorf("process is shutting down")
|
||||
default:
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// delayedHealthCheck wraps a health check which will not fail until the explicitly defined delay has elapsed. This
|
||||
// is intended for use primarily for livez health checks.
|
||||
func delayedHealthCheck(check healthz.HealthChecker, clock clock.Clock, delay time.Duration) healthz.HealthChecker {
|
||||
|
|
|
|||
|
|
@ -105,6 +105,29 @@ func (i *informerSync) Name() string {
|
|||
return "informer-sync"
|
||||
}
|
||||
|
||||
type shutdown struct {
|
||||
stopCh <-chan struct{}
|
||||
}
|
||||
|
||||
// NewShutdownHealthz returns a new HealthChecker that will fail if the embedded channel is closed.
|
||||
// This is intended to allow for graceful shutdown sequences.
|
||||
func NewShutdownHealthz(stopCh <-chan struct{}) HealthChecker {
|
||||
return &shutdown{stopCh}
|
||||
}
|
||||
|
||||
func (s *shutdown) Name() string {
|
||||
return "shutdown"
|
||||
}
|
||||
|
||||
func (s *shutdown) Check(req *http.Request) error {
|
||||
select {
|
||||
case <-s.stopCh:
|
||||
return fmt.Errorf("process is shutting down")
|
||||
default:
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (i *informerSync) Check(_ *http.Request) error {
|
||||
stopCh := make(chan struct{})
|
||||
// Close stopCh to force checking if informers are synced now.
|
||||
|
|
|
|||
Loading…
Reference in New Issue