From c51fc2986b50a36cbd31e001e4d57097af1799a0 Mon Sep 17 00:00:00 2001 From: hzxuzhonghu Date: Sun, 11 Feb 2018 14:42:59 +0800 Subject: [PATCH] controller-manager make use of generic apiserver profiling --- cmd/controller-manager/app/serve.go | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/cmd/controller-manager/app/serve.go b/cmd/controller-manager/app/serve.go index f75777ed266..7a9d36d1143 100644 --- a/cmd/controller-manager/app/serve.go +++ b/cmd/controller-manager/app/serve.go @@ -18,7 +18,6 @@ package app import ( "net/http" - "net/http/pprof" goruntime "runtime" "time" @@ -28,6 +27,8 @@ import ( apirequest "k8s.io/apiserver/pkg/endpoints/request" genericfilters "k8s.io/apiserver/pkg/server/filters" "k8s.io/apiserver/pkg/server/healthz" + "k8s.io/apiserver/pkg/server/mux" + "k8s.io/apiserver/pkg/server/routes" "k8s.io/kubernetes/pkg/api/legacyscheme" "k8s.io/kubernetes/pkg/util/configz" ) @@ -37,13 +38,10 @@ type serveFunc func(handler http.Handler, shutdownTimeout time.Duration, stopCh // Serve creates a base handler chain for a controller manager. It runs the // the chain with the given serveFunc. func Serve(c *CompletedConfig, serveFunc serveFunc, stopCh <-chan struct{}) error { - mux := http.NewServeMux() + mux := mux.NewPathRecorderMux("controller-manager") healthz.InstallHandler(mux) if c.ComponentConfig.EnableProfiling { - mux.HandleFunc("/debug/pprof/", pprof.Index) - mux.HandleFunc("/debug/pprof/profile", pprof.Profile) - mux.HandleFunc("/debug/pprof/symbol", pprof.Symbol) - mux.HandleFunc("/debug/pprof/trace", pprof.Trace) + routes.Profiling{}.Install(mux) if c.ComponentConfig.EnableContentionProfiling { goruntime.SetBlockProfileRate(1) }