Skip to content

Commit

Permalink
Fix controller flag handling 🙃
Browse files Browse the repository at this point in the history
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 <[email protected]>
  • Loading branch information
vdemeester authored and tekton-robot committed Jan 8, 2021
1 parent 52243be commit f121db9
Showing 1 changed file with 11 additions and 9 deletions.
20 changes: 11 additions & 9 deletions cmd/controller/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,16 +51,15 @@ 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 "+
"issue upstream!")
)

func main() {
flag.Parse()
cfg := sharedmain.ParseAndGetConfigOrDie()
controller.DefaultThreadsPerController = *threadsPerController
version.SetVersion(*versionGiven)
images := pipeline.Images{
EntrypointImage: *entrypointImage,
Expand All @@ -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 {
Expand Down

0 comments on commit f121db9

Please sign in to comment.