mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-09-25 12:17:52 +00:00
Fixing scheduling latency metrics
This commit is contained in:
@@ -21,6 +21,7 @@ go_library(
|
||||
"//pkg/scheduler/api:go_default_library",
|
||||
"//pkg/scheduler/api/latest:go_default_library",
|
||||
"//pkg/scheduler/factory:go_default_library",
|
||||
"//pkg/scheduler/metrics:go_default_library",
|
||||
"//pkg/util/configz:go_default_library",
|
||||
"//pkg/util/flag:go_default_library",
|
||||
"//pkg/version:go_default_library",
|
||||
|
@@ -19,6 +19,7 @@ package app
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"io"
|
||||
"io/ioutil"
|
||||
"net/http"
|
||||
"os"
|
||||
@@ -51,6 +52,7 @@ import (
|
||||
schedulerapi "k8s.io/kubernetes/pkg/scheduler/api"
|
||||
latestschedulerapi "k8s.io/kubernetes/pkg/scheduler/api/latest"
|
||||
"k8s.io/kubernetes/pkg/scheduler/factory"
|
||||
"k8s.io/kubernetes/pkg/scheduler/metrics"
|
||||
"k8s.io/kubernetes/pkg/util/configz"
|
||||
utilflag "k8s.io/kubernetes/pkg/util/flag"
|
||||
"k8s.io/kubernetes/pkg/version"
|
||||
@@ -221,11 +223,23 @@ func buildHandlerChain(handler http.Handler, authn authenticator.Request, authz
|
||||
return handler
|
||||
}
|
||||
|
||||
func installMetricHandler(pathRecorderMux *mux.PathRecorderMux) {
|
||||
configz.InstallHandler(pathRecorderMux)
|
||||
defaultMetricsHandler := prometheus.Handler().ServeHTTP
|
||||
pathRecorderMux.HandleFunc("/metrics", func(w http.ResponseWriter, req *http.Request) {
|
||||
if req.Method == "DELETE" {
|
||||
metrics.Reset()
|
||||
io.WriteString(w, "metrics reset\n")
|
||||
return
|
||||
}
|
||||
defaultMetricsHandler(w, req)
|
||||
})
|
||||
}
|
||||
|
||||
// newMetricsHandler builds a metrics server from the config.
|
||||
func newMetricsHandler(config *componentconfig.KubeSchedulerConfiguration) http.Handler {
|
||||
pathRecorderMux := mux.NewPathRecorderMux("kube-scheduler")
|
||||
configz.InstallHandler(pathRecorderMux)
|
||||
pathRecorderMux.Handle("/metrics", prometheus.Handler())
|
||||
installMetricHandler(pathRecorderMux)
|
||||
if config.EnableProfiling {
|
||||
routes.Profiling{}.Install(pathRecorderMux)
|
||||
if config.EnableContentionProfiling {
|
||||
@@ -242,8 +256,7 @@ func newHealthzHandler(config *componentconfig.KubeSchedulerConfiguration, separ
|
||||
pathRecorderMux := mux.NewPathRecorderMux("kube-scheduler")
|
||||
healthz.InstallHandler(pathRecorderMux)
|
||||
if !separateMetrics {
|
||||
configz.InstallHandler(pathRecorderMux)
|
||||
pathRecorderMux.Handle("/metrics", prometheus.Handler())
|
||||
installMetricHandler(pathRecorderMux)
|
||||
}
|
||||
if config.EnableProfiling {
|
||||
routes.Profiling{}.Install(pathRecorderMux)
|
||||
|
Reference in New Issue
Block a user