Allow configuration of threads-per-controller (#2567)

This commit is contained in:
Sascha Schwarze 2022-09-14 17:47:04 +02:00 committed by GitHub
parent 717747b6ba
commit 5f66ecf267
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 9 additions and 0 deletions

View File

@ -24,6 +24,7 @@ import (
"log" "log"
"net/http" "net/http"
"os" "os"
"strconv"
"strings" "strings"
"time" "time"
@ -165,6 +166,14 @@ func toControllerConstructors(namedCtors []injection.NamedControllerConstructor)
// MainWithContext runs the generic main flow for controllers and // MainWithContext runs the generic main flow for controllers and
// webhooks. Use MainWithContext if you do not need to serve webhooks. // webhooks. Use MainWithContext if you do not need to serve webhooks.
func MainWithContext(ctx context.Context, component string, ctors ...injection.ControllerConstructor) { func MainWithContext(ctx context.Context, component string, ctors ...injection.ControllerConstructor) {
// Allow configuration of threads per controller
if val, ok := os.LookupEnv("K_THREADS_PER_CONTROLLER"); ok {
threadsPerController, err := strconv.Atoi(val)
if err != nil {
log.Fatalf("failed to parse value %q of K_THREADS_PER_CONTROLLER: %v\n", val, err)
}
controller.DefaultThreadsPerController = threadsPerController
}
// TODO(mattmoor): Remove this once HA is stable. // TODO(mattmoor): Remove this once HA is stable.
disableHighAvailability := flag.Bool("disable-ha", false, disableHighAvailability := flag.Bool("disable-ha", false,