Skip to content

Commit

Permalink
Expose Resolvers Controller performance tuning configurations
Browse files Browse the repository at this point in the history
This changes the resolvers controllers to start with a config.
We expose ThreadsPerController, QPS and Burst for performance
tuning as we do for pipelines controller.
  • Loading branch information
khrm authored and tekton-robot committed Nov 5, 2024
1 parent 96db451 commit 19ccc64
Showing 1 changed file with 20 additions and 1 deletion.
21 changes: 20 additions & 1 deletion cmd/resolvers/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ limitations under the License.
package main

import (
"flag"
"os"
"strings"

Expand All @@ -28,17 +29,35 @@ import (
"github.com/tektoncd/pipeline/pkg/remoteresolution/resolver/http"
"github.com/tektoncd/pipeline/pkg/remoteresolution/resolver/hub"
hubresolution "github.com/tektoncd/pipeline/pkg/resolution/resolver/hub"
"k8s.io/client-go/rest"
filteredinformerfactory "knative.dev/pkg/client/injection/kube/informers/factory/filtered"
"knative.dev/pkg/controller"
"knative.dev/pkg/injection"
"knative.dev/pkg/injection/sharedmain"
"knative.dev/pkg/signals"
)

func main() {
flag.IntVar(&controller.DefaultThreadsPerController, "threads-per-controller", controller.DefaultThreadsPerController, "Threads (goroutines) to create per controller")

ctx := filteredinformerfactory.WithSelectors(signals.NewContext(), v1alpha1.ManagedByLabelKey)
tektonHubURL := buildHubURL(os.Getenv("TEKTON_HUB_API"), "")
artifactHubURL := buildHubURL(os.Getenv("ARTIFACT_HUB_API"), hubresolution.DefaultArtifactHubURL)

sharedmain.MainWithContext(ctx, "controller",
// This parses flags.
cfg := injection.ParseAndGetRESTConfigOrDie()

if cfg.QPS == 0 {
cfg.QPS = 2 * rest.DefaultQPS
}
if cfg.Burst == 0 {
cfg.Burst = rest.DefaultBurst
}
// multiply by no of controllers being created
cfg.QPS = 5 * cfg.QPS
cfg.Burst = 5 * cfg.Burst

sharedmain.MainWithConfig(ctx, "controller", cfg,
framework.NewController(ctx, &git.Resolver{}),
framework.NewController(ctx, &hub.Resolver{TektonHubURL: tektonHubURL, ArtifactHubURL: artifactHubURL}),
framework.NewController(ctx, &bundle.Resolver{}),
Expand Down

0 comments on commit 19ccc64

Please sign in to comment.