From f121db996dbc1867d8f6616c887c1374a5770db2 Mon Sep 17 00:00:00 2001 From: Vincent Demeester Date: Thu, 7 Jan 2021 15:39:44 +0100 Subject: [PATCH] =?UTF-8?q?Fix=20controller=20flag=20handling=20?= =?UTF-8?q?=F0=9F=99=83?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Do not call flag.Parse() as it happens in `sharedmain.ParseAndGetConfigOrDie`. Move anything that needs the flag value after that call. This also does something with QPS and Burst flag are they are already defined in knative/pkg *but* with different default. Signed-off-by: Vincent Demeester --- cmd/controller/main.go | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/cmd/controller/main.go b/cmd/controller/main.go index 9b597d24d11..d257e822821 100644 --- a/cmd/controller/main.go +++ b/cmd/controller/main.go @@ -51,8 +51,6 @@ var ( imageDigestExporterImage = flag.String("imagedigest-exporter-image", "", "The container image containing our image digest exporter binary.") namespace = flag.String("namespace", corev1.NamespaceAll, "Namespace to restrict informer to. Optional, defaults to all namespaces.") versionGiven = flag.String("version", "devel", "Version of Tekton running") - qps = flag.Int("kube-api-qps", int(rest.DefaultQPS), "Maximum QPS to the master from this client") - burst = flag.Int("kube-api-burst", rest.DefaultBurst, "Maximum burst for throttle") threadsPerController = flag.Int("threads-per-controller", controller.DefaultThreadsPerController, "Threads (goroutines) to create per controller") disableHighAvailability = flag.Bool("disable-ha", false, "Whether to disable high-availability functionality for this component. This flag will be deprecated "+ "and removed when we have promoted this feature to stable, so do not pass it without filing an "+ @@ -60,7 +58,8 @@ var ( ) func main() { - flag.Parse() + cfg := sharedmain.ParseAndGetConfigOrDie() + controller.DefaultThreadsPerController = *threadsPerController version.SetVersion(*versionGiven) images := pipeline.Images{ EntrypointImage: *entrypointImage, @@ -76,13 +75,16 @@ func main() { if err := images.Validate(); err != nil { log.Fatal(err) } - - controller.DefaultThreadsPerController = *threadsPerController - - cfg := sharedmain.ParseAndGetConfigOrDie() + if cfg.QPS == 0 { + cfg.QPS = 2 * rest.DefaultQPS + } + if cfg.Burst == 0 { + cfg.Burst = rest.DefaultBurst + } + // FIXME(vdemeester): this is here to not break current behavior // multiply by 2, no of controllers being created - cfg.QPS = 2 * float32(*qps) - cfg.Burst = 2 * *burst + cfg.QPS = 2 * cfg.QPS + cfg.Burst = 2 * cfg.Burst ctx := injection.WithNamespaceScope(signals.NewContext(), *namespace) if *disableHighAvailability {