From e85ebccb57b8bbde43153005d2d0f0590f0a0d5f Mon Sep 17 00:00:00 2001 From: Alex Wang Date: Wed, 6 Nov 2019 15:25:35 +0800 Subject: [PATCH] enable profiling by default in the scheduler --- .../app/options/options_test.go | 24 +++++++++++++++++++ .../apis/config/v1alpha1/defaults.go | 12 ++++++++++ .../apis/config/v1alpha1/defaults_test.go | 13 ++++++++++ 3 files changed, 49 insertions(+) diff --git a/cmd/kube-scheduler/app/options/options_test.go b/cmd/kube-scheduler/app/options/options_test.go index ec7a2614b76..160f663ebf1 100644 --- a/cmd/kube-scheduler/app/options/options_test.go +++ b/cmd/kube-scheduler/app/options/options_test.go @@ -260,6 +260,10 @@ pluginConfig: HardPodAffinitySymmetricWeight: 1, HealthzBindAddress: "0.0.0.0:10251", MetricsBindAddress: "0.0.0.0:10251", + DebuggingConfiguration: componentbaseconfig.DebuggingConfiguration{ + EnableProfiling: true, + EnableContentionProfiling: true, + }, LeaderElection: kubeschedulerconfig.KubeSchedulerLeaderElectionConfiguration{ LeaderElectionConfiguration: componentbaseconfig.LeaderElectionConfiguration{ LeaderElect: true, @@ -343,6 +347,10 @@ pluginConfig: HardPodAffinitySymmetricWeight: 1, HealthzBindAddress: "", // defaults empty when not running from config file MetricsBindAddress: "", // defaults empty when not running from config file + DebuggingConfiguration: componentbaseconfig.DebuggingConfiguration{ + EnableProfiling: true, + EnableContentionProfiling: true, + }, LeaderElection: kubeschedulerconfig.KubeSchedulerLeaderElectionConfiguration{ LeaderElectionConfiguration: componentbaseconfig.LeaderElectionConfiguration{ LeaderElect: true, @@ -404,6 +412,10 @@ pluginConfig: HardPodAffinitySymmetricWeight: 1, HealthzBindAddress: "", // defaults empty when not running from config file MetricsBindAddress: "", // defaults empty when not running from config file + DebuggingConfiguration: componentbaseconfig.DebuggingConfiguration{ + EnableProfiling: true, + EnableContentionProfiling: true, + }, LeaderElection: kubeschedulerconfig.KubeSchedulerLeaderElectionConfiguration{ LeaderElectionConfiguration: componentbaseconfig.LeaderElectionConfiguration{ LeaderElect: true, @@ -440,6 +452,10 @@ pluginConfig: HardPodAffinitySymmetricWeight: 1, HealthzBindAddress: "0.0.0.0:10251", MetricsBindAddress: "0.0.0.0:10251", + DebuggingConfiguration: componentbaseconfig.DebuggingConfiguration{ + EnableProfiling: true, + EnableContentionProfiling: true, + }, LeaderElection: kubeschedulerconfig.KubeSchedulerLeaderElectionConfiguration{ LeaderElectionConfiguration: componentbaseconfig.LeaderElectionConfiguration{ LeaderElect: true, @@ -518,6 +534,10 @@ pluginConfig: HardPodAffinitySymmetricWeight: 1, HealthzBindAddress: "0.0.0.0:10251", MetricsBindAddress: "0.0.0.0:10251", + DebuggingConfiguration: componentbaseconfig.DebuggingConfiguration{ + EnableProfiling: true, + EnableContentionProfiling: true, + }, LeaderElection: kubeschedulerconfig.KubeSchedulerLeaderElectionConfiguration{ LeaderElectionConfiguration: componentbaseconfig.LeaderElectionConfiguration{ LeaderElect: true, @@ -557,6 +577,10 @@ pluginConfig: HardPodAffinitySymmetricWeight: 1, HealthzBindAddress: "0.0.0.0:10251", MetricsBindAddress: "0.0.0.0:10251", + DebuggingConfiguration: componentbaseconfig.DebuggingConfiguration{ + EnableProfiling: true, + EnableContentionProfiling: true, + }, LeaderElection: kubeschedulerconfig.KubeSchedulerLeaderElectionConfiguration{ LeaderElectionConfiguration: componentbaseconfig.LeaderElectionConfiguration{ LeaderElect: false, diff --git a/pkg/scheduler/apis/config/v1alpha1/defaults.go b/pkg/scheduler/apis/config/v1alpha1/defaults.go index 73a24e96522..a618d90f592 100644 --- a/pkg/scheduler/apis/config/v1alpha1/defaults.go +++ b/pkg/scheduler/apis/config/v1alpha1/defaults.go @@ -156,4 +156,16 @@ func SetDefaults_KubeSchedulerConfiguration(obj *kubeschedulerconfigv1alpha1.Kub val := int64(10) obj.PodMaxBackoffSeconds = &val } + + // Enable profiling by default in the scheduler + if obj.EnableProfiling == nil { + enableProfiling := true + obj.EnableProfiling = &enableProfiling + } + + // Enable contention profiling by default if profiling is enabled + if *obj.EnableProfiling && obj.EnableContentionProfiling == nil { + enableContentionProfiling := true + obj.EnableContentionProfiling = &enableContentionProfiling + } } diff --git a/pkg/scheduler/apis/config/v1alpha1/defaults_test.go b/pkg/scheduler/apis/config/v1alpha1/defaults_test.go index b39eeb18f9c..bdd8522db26 100644 --- a/pkg/scheduler/apis/config/v1alpha1/defaults_test.go +++ b/pkg/scheduler/apis/config/v1alpha1/defaults_test.go @@ -28,6 +28,7 @@ import ( ) func TestSchedulerDefaults(t *testing.T) { + enable := true tests := []struct { name string config *kubeschedulerconfigv1alpha1.KubeSchedulerConfiguration @@ -42,6 +43,10 @@ func TestSchedulerDefaults(t *testing.T) { HardPodAffinitySymmetricWeight: pointer.Int32Ptr(1), HealthzBindAddress: pointer.StringPtr("0.0.0.0:10251"), MetricsBindAddress: pointer.StringPtr("0.0.0.0:10251"), + DebuggingConfiguration: componentbaseconfig.DebuggingConfiguration{ + EnableProfiling: &enable, + EnableContentionProfiling: &enable, + }, LeaderElection: kubeschedulerconfigv1alpha1.KubeSchedulerLeaderElectionConfiguration{ LeaderElectionConfiguration: componentbaseconfig.LeaderElectionConfiguration{ LeaderElect: pointer.BoolPtr(true), @@ -80,6 +85,10 @@ func TestSchedulerDefaults(t *testing.T) { HardPodAffinitySymmetricWeight: pointer.Int32Ptr(1), HealthzBindAddress: pointer.StringPtr("1.2.3.4:10251"), MetricsBindAddress: pointer.StringPtr("1.2.3.4:10251"), + DebuggingConfiguration: componentbaseconfig.DebuggingConfiguration{ + EnableProfiling: &enable, + EnableContentionProfiling: &enable, + }, LeaderElection: kubeschedulerconfigv1alpha1.KubeSchedulerLeaderElectionConfiguration{ LeaderElectionConfiguration: componentbaseconfig.LeaderElectionConfiguration{ LeaderElect: pointer.BoolPtr(true), @@ -118,6 +127,10 @@ func TestSchedulerDefaults(t *testing.T) { HardPodAffinitySymmetricWeight: pointer.Int32Ptr(1), HealthzBindAddress: pointer.StringPtr("0.0.0.0:12345"), MetricsBindAddress: pointer.StringPtr("0.0.0.0:12345"), + DebuggingConfiguration: componentbaseconfig.DebuggingConfiguration{ + EnableProfiling: &enable, + EnableContentionProfiling: &enable, + }, LeaderElection: kubeschedulerconfigv1alpha1.KubeSchedulerLeaderElectionConfiguration{ LeaderElectionConfiguration: componentbaseconfig.LeaderElectionConfiguration{ LeaderElect: pointer.BoolPtr(true),