Skip to content

Commit

Permalink
make rbac max concurrent calls configurable via env variable
Browse files Browse the repository at this point in the history
  • Loading branch information
jkhelil committed Sep 17, 2024
1 parent 501f4e4 commit 1cc8aa8
Showing 1 changed file with 15 additions and 2 deletions.
17 changes: 15 additions & 2 deletions pkg/reconciler/openshift/tektonconfig/rbac.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,9 @@ import (
"context"
"fmt"
"math"
"os"
"regexp"
"strconv"
"sync"
"time"

Expand Down Expand Up @@ -68,7 +70,7 @@ const (
rbacParamName = "createRbacResource"
serviceAccountCreationLabel = "openshift-pipelines.tekton.dev/sa-created"

rbacMaxConcurrentCalls = 20
defaultRbacMaxConcurrentCalls = 20
)

var (
Expand Down Expand Up @@ -376,6 +378,17 @@ func (r *rbac) handleSCCInNamespace(ctx context.Context, ns *corev1.Namespace) e
return nil
}

func getRBACMaxCalls() int {
envValue := os.Getenv("OCP_RBAC_MAX_CONCURRENT_CALLS")
if envValue == "" {
return defaultRbacMaxConcurrentCalls
}
if parsedValue, err := strconv.Atoi(envValue); err == nil {
return parsedValue
}
return defaultRbacMaxConcurrentCalls
}

func (r *rbac) createResources(ctx context.Context) error {
logger := logging.FromContext(ctx)

Expand All @@ -402,7 +415,7 @@ func (r *rbac) createResources(ctx context.Context) error {
var wg sync.WaitGroup

// Start worker pool
for i := 0; i < rbacMaxConcurrentCalls; i++ {
for i := 0; i < getRBACMaxCalls(); i++ {
wg.Add(1)
go r.nsWorker(ctx, &wg, jobs, errCh)
}
Expand Down

0 comments on commit 1cc8aa8

Please sign in to comment.