From e1e84c8e5f56d0f6e709e418839662200243ec90 Mon Sep 17 00:00:00 2001 From: Patrick Ohly Date: Mon, 7 Feb 2022 09:12:10 +0100 Subject: [PATCH] scheduler_perf: run with -v=0 by default This provides a mechanism for overriding the forced increase of the klog verbosity to 4 when starting the apiserver and uses that for the scheduler_perf benchmark. Other tests run as before. A global variable was used because adding an explicit parameter to several helper functions would have caused a lot of code churn (test -> integration/util.StartApiserver -> integration/framework.RunAnAPIServerUsingServer -> integration/framework.startAPIServerOrDie). --- test/integration/framework/controlplane_utils.go | 13 ++++++++++--- test/integration/scheduler_perf/util.go | 3 +++ 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/test/integration/framework/controlplane_utils.go b/test/integration/framework/controlplane_utils.go index 8b1421f8f12..a476611459a 100644 --- a/test/integration/framework/controlplane_utils.go +++ b/test/integration/framework/controlplane_utils.go @@ -65,6 +65,13 @@ const ( UnprivilegedUserToken = "unprivileged-user" ) +// MinVerbosity determines the minimum klog verbosity when running tests that +// involve the apiserver. This overrides the -v value from the command line, +// i.e. -v=0 has no effect when MinVerbosity is 4 (the default). Tests can opt +// out of this by setting MinVerbosity to zero before starting the control +// plane or choose some different minimum verbosity. +var MinVerbosity = 4 + // Config is a struct of configuration directives for NewControlPlaneComponents. type Config struct { // If nil, a default is used, partially filled configs will not get populated. @@ -139,11 +146,11 @@ func startAPIServerOrDie(controlPlaneConfig *controlplane.Config, incomingServer var m *controlplane.Instance var s *httptest.Server - // Ensure we log at least level 4 + // Ensure we log at least at the desired level v := flag.Lookup("v").Value level, _ := strconv.Atoi(v.String()) - if level < 4 { - v.Set("4") + if level < MinVerbosity { + v.Set(strconv.Itoa(MinVerbosity)) } if incomingServer != nil { diff --git a/test/integration/scheduler_perf/util.go b/test/integration/scheduler_perf/util.go index 18f2f7cb8eb..e2168986f57 100644 --- a/test/integration/scheduler_perf/util.go +++ b/test/integration/scheduler_perf/util.go @@ -44,6 +44,7 @@ import ( "k8s.io/kube-scheduler/config/v1beta2" "k8s.io/kubernetes/pkg/scheduler/apis/config" kubeschedulerscheme "k8s.io/kubernetes/pkg/scheduler/apis/config/scheme" + "k8s.io/kubernetes/test/integration/framework" "k8s.io/kubernetes/test/integration/util" testutils "k8s.io/kubernetes/test/utils" ) @@ -75,6 +76,8 @@ func newDefaultComponentConfig() (*config.KubeSchedulerConfiguration, error) { // Notes on rate limiter: // - client rate limit is set to 5000. func mustSetupScheduler(config *config.KubeSchedulerConfiguration) (util.ShutdownFunc, coreinformers.PodInformer, clientset.Interface, dynamic.Interface) { + // Run API server with minimimal logging by default. Can be raised with -v. + framework.MinVerbosity = 0 apiURL, apiShutdown := util.StartApiserver() var err error