mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-08-09 03:57:41 +00:00
DefaultMux should only register the first time
This commit is contained in:
parent
1f628f2340
commit
c54097d96c
@ -20,6 +20,7 @@ import (
|
|||||||
"bytes"
|
"bytes"
|
||||||
"fmt"
|
"fmt"
|
||||||
"net/http"
|
"net/http"
|
||||||
|
"sync"
|
||||||
)
|
)
|
||||||
|
|
||||||
// HealthzChecker is a named healthz check.
|
// HealthzChecker is a named healthz check.
|
||||||
@ -28,9 +29,13 @@ type HealthzChecker interface {
|
|||||||
Check(req *http.Request) error
|
Check(req *http.Request) error
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var defaultHealthz = sync.Once{}
|
||||||
|
|
||||||
// DefaultHealthz installs the default healthz check to the http.DefaultServeMux.
|
// DefaultHealthz installs the default healthz check to the http.DefaultServeMux.
|
||||||
func DefaultHealthz(checks ...HealthzChecker) {
|
func DefaultHealthz(checks ...HealthzChecker) {
|
||||||
|
defaultHealthz.Do(func() {
|
||||||
InstallHandler(http.DefaultServeMux, checks...)
|
InstallHandler(http.DefaultServeMux, checks...)
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
// PingHealthz returns true automatically when checked
|
// PingHealthz returns true automatically when checked
|
||||||
|
Loading…
Reference in New Issue
Block a user