diff --git a/Godeps/Godeps.json b/Godeps/Godeps.json index 4e20c880b..c7a9f29b5 100644 --- a/Godeps/Godeps.json +++ b/Godeps/Godeps.json @@ -668,15 +668,15 @@ }, { "ImportPath": "k8s.io/api", - "Rev": "3b5342aabbeb" + "Rev": "aaebd44608df" }, { "ImportPath": "k8s.io/apimachinery", - "Rev": "640343330969" + "Rev": "4149bbf8192b" }, { "ImportPath": "k8s.io/client-go", - "Rev": "db5293afc7bf" + "Rev": "03667fd6b18f" }, { "ImportPath": "k8s.io/component-base", diff --git a/go.mod b/go.mod index c3734fc98..19786096c 100644 --- a/go.mod +++ b/go.mod @@ -41,9 +41,9 @@ require ( gopkg.in/natefinch/lumberjack.v2 v2.0.0 gopkg.in/square/go-jose.v2 v2.2.2 gopkg.in/yaml.v2 v2.2.8 - k8s.io/api v0.0.0-20200627130740-3b5342aabbeb - k8s.io/apimachinery v0.0.0-20200627130346-640343330969 - k8s.io/client-go v0.0.0-20200626130735-db5293afc7bf + k8s.io/api v0.0.0-20200630090439-aaebd44608df + k8s.io/apimachinery v0.0.0-20200630203207-4149bbf8192b + k8s.io/client-go v0.0.0-20200630090720-03667fd6b18f k8s.io/component-base v0.0.0-20200626131333-f52a9b7250e8 k8s.io/klog/v2 v2.1.0 k8s.io/kube-openapi v0.0.0-20200427153329-656914f816f9 @@ -54,8 +54,8 @@ require ( ) replace ( - k8s.io/api => k8s.io/api v0.0.0-20200627130740-3b5342aabbeb - k8s.io/apimachinery => k8s.io/apimachinery v0.0.0-20200627130346-640343330969 - k8s.io/client-go => k8s.io/client-go v0.0.0-20200626130735-db5293afc7bf + k8s.io/api => k8s.io/api v0.0.0-20200630090439-aaebd44608df + k8s.io/apimachinery => k8s.io/apimachinery v0.0.0-20200630203207-4149bbf8192b + k8s.io/client-go => k8s.io/client-go v0.0.0-20200630090720-03667fd6b18f k8s.io/component-base => k8s.io/component-base v0.0.0-20200626131333-f52a9b7250e8 ) diff --git a/go.sum b/go.sum index 3c05f71d4..0c8f19e62 100644 --- a/go.sum +++ b/go.sum @@ -506,9 +506,9 @@ honnef.co/go/tools v0.0.0-20190106161140-3f1c8253044a/go.mod h1:rf3lG4BRIbNafJWh honnef.co/go/tools v0.0.0-20190418001031-e561f6794a2a/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= honnef.co/go/tools v0.0.0-20190523083050-ea95bdfd59fc/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= honnef.co/go/tools v0.0.1-2019.2.3/go.mod h1:a3bituU0lyd329TUQxRnasdCoJDkEUEAqEt0JzvZhAg= -k8s.io/api v0.0.0-20200627130740-3b5342aabbeb/go.mod h1:vQNZO9B7m8N2djMqqgLa34Z2LCUrTXLWN98egCzDhrU= -k8s.io/apimachinery v0.0.0-20200627130346-640343330969/go.mod h1:m5QoVMHU94aieNFPfLqf7WmU8HLVLm3JasG64COkSXQ= -k8s.io/client-go v0.0.0-20200626130735-db5293afc7bf/go.mod h1:xWyNNU1CYxp5Qle29OSU49QrlzME3jkGOpv9FsbIFr4= +k8s.io/api v0.0.0-20200630090439-aaebd44608df/go.mod h1:cQk/DBCsCL81chJRAZjSBZ4suDeNugUZE3LqnYmbQ8Q= +k8s.io/apimachinery v0.0.0-20200630203207-4149bbf8192b/go.mod h1:m5QoVMHU94aieNFPfLqf7WmU8HLVLm3JasG64COkSXQ= +k8s.io/client-go v0.0.0-20200630090720-03667fd6b18f/go.mod h1:emGJ1Ok1wvvwJsDNayMzuFecdtLv6Yr7HJnpojOq+AI= k8s.io/component-base v0.0.0-20200626131333-f52a9b7250e8/go.mod h1:c8B2Gs7ipNKY0Hn4SBgCBsMo38vovG9B2E90kf+Fg1E= k8s.io/gengo v0.0.0-20200413195148-3a45101e95ac/go.mod h1:ezvh/TsK7cY6rbqRK0oQQ8IAqLxYwwyPxAX1Pzy0ii0= k8s.io/klog/v2 v2.0.0 h1:Foj74zO6RbjjP4hBEKjnYtjjAhGg4jNynUdYF6fJrok= diff --git a/pkg/server/healthz/healthz.go b/pkg/server/healthz/healthz.go index e558098de..408412f1d 100644 --- a/pkg/server/healthz/healthz.go +++ b/pkg/server/healthz/healthz.go @@ -172,35 +172,38 @@ func getExcludedChecks(r *http.Request) sets.String { // handleRootHealthz returns an http.HandlerFunc that serves the provided checks. func handleRootHealthz(checks ...HealthChecker) http.HandlerFunc { return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { - failed := false excluded := getExcludedChecks(r) - var verboseOut bytes.Buffer + // failedVerboseLogOutput is for output to the log. It indicates detailed failed output information for the log. + var failedVerboseLogOutput bytes.Buffer + var failedChecks []string + var individualCheckOutput bytes.Buffer for _, check := range checks { // no-op the check if we've specified we want to exclude the check if excluded.Has(check.Name()) { excluded.Delete(check.Name()) - fmt.Fprintf(&verboseOut, "[+]%v excluded: ok\n", check.Name()) + fmt.Fprintf(&individualCheckOutput, "[+]%s excluded: ok\n", check.Name()) continue } if err := check.Check(r); err != nil { // don't include the error since this endpoint is public. If someone wants more detail // they should have explicit permission to the detailed checks. - klog.V(4).Infof("healthz check %v failed: %v", check.Name(), err) - fmt.Fprintf(&verboseOut, "[-]%v failed: reason withheld\n", check.Name()) - failed = true + fmt.Fprintf(&individualCheckOutput, "[-]%s failed: reason withheld\n", check.Name()) + // but we do want detailed information for our log + fmt.Fprintf(&failedVerboseLogOutput, "[-]%s failed: %v\n", check.Name(), err) + failedChecks = append(failedChecks, check.Name()) } else { - fmt.Fprintf(&verboseOut, "[+]%v ok\n", check.Name()) + fmt.Fprintf(&individualCheckOutput, "[+]%s ok\n", check.Name()) } } if excluded.Len() > 0 { - fmt.Fprintf(&verboseOut, "warn: some health checks cannot be excluded: no matches for %v\n", formatQuoted(excluded.List()...)) - klog.Warningf("cannot exclude some health checks, no health checks are installed matching %v", + fmt.Fprintf(&individualCheckOutput, "warn: some health checks cannot be excluded: no matches for %s\n", formatQuoted(excluded.List()...)) + klog.Warningf("cannot exclude some health checks, no health checks are installed matching %s", formatQuoted(excluded.List()...)) } // always be verbose on failure - if failed { - klog.V(2).Infof("%vhealthz check failed", verboseOut.String()) - http.Error(httplog.Unlogged(r, w), fmt.Sprintf("%vhealthz check failed", verboseOut.String()), http.StatusInternalServerError) + if len(failedChecks) > 0 { + klog.V(2).Infof("healthz check failed: %s\n%v", strings.Join(failedChecks, ","), failedVerboseLogOutput.String()) + http.Error(httplog.Unlogged(r, w), fmt.Sprintf("%shealthz check failed", individualCheckOutput.String()), http.StatusInternalServerError) return } @@ -211,7 +214,7 @@ func handleRootHealthz(checks ...HealthChecker) http.HandlerFunc { return } - verboseOut.WriteTo(w) + individualCheckOutput.WriteTo(w) fmt.Fprint(w, "healthz check passed\n") }) }