Skip to content

Commit

Permalink
Configurable number of workloads for both controllers with default va…
Browse files Browse the repository at this point in the history
…lue 25
  • Loading branch information
koala7659 committed Dec 9, 2024
1 parent 1b07eee commit 9cb19cb
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 9 deletions.
10 changes: 8 additions & 2 deletions cmd/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,8 @@ const (
defaultShootCreateRequeueDuration = 60 * time.Second
defaultShootDeleteRequeueDuration = 90 * time.Second
defaultShootReconcileRequeueDuration = 30 * time.Second
defaultRuntimeCtrlWorkersCnt = 25
defaultGardenerClusterCtrlWorkersCnt = 25
)

func main() {
Expand All @@ -97,6 +99,8 @@ func main() {
var runtimeCtrlGardenerRequestTimeout time.Duration
var runtimeCtrlGardenerRateLimiterQPS int
var runtimeCtrlGardenerRateLimiterBurst int
var runtimeCtrlWorkersCnt int
var gardenerClusterCtrlWorkersCnt int
var converterConfigFilepath string
var shootSpecDumpEnabled bool
var auditLogMandatory bool
Expand All @@ -114,6 +118,8 @@ func main() {
flag.DurationVar(&runtimeCtrlGardenerRequestTimeout, "gardener-request-timeout", defaultGardenerRequestTimeout, "Timeout duration for Gardener client for Runtime Controller")
flag.IntVar(&runtimeCtrlGardenerRateLimiterQPS, "gardener-ratelimiter-qps", defaultGardenerRateLimiterQPS, "Gardener client rate limiter QPS for Runtime Controller")
flag.IntVar(&runtimeCtrlGardenerRateLimiterBurst, "gardener-ratelimiter-burst", defaultGardenerRateLimiterBurst, "Gardener client rate limiter burst for Runtime Controller")
flag.IntVar(&runtimeCtrlWorkersCnt, "runtime-ctrl-workers-cnt", defaultRuntimeCtrlWorkersCnt, "A number of workers running in parallel for Runtime Controller")
flag.IntVar(&gardenerClusterCtrlWorkersCnt, "gardener-cluster-ctrl-workers-cnt", defaultGardenerClusterCtrlWorkersCnt, "A number of workers running in parallel for Gardener Cluster Controller")
flag.StringVar(&converterConfigFilepath, "converter-config-filepath", "/converter-config/converter_config.json", "A file path to the gardener shoot converter configuration.")
flag.BoolVar(&shootSpecDumpEnabled, "shoot-spec-dump-enabled", false, "Feature flag to allow persisting specs of created shoots")
flag.BoolVar(&auditLogMandatory, "audit-log-mandatory", true, "Feature flag to enable strict mode for audit log configuration")
Expand Down Expand Up @@ -178,7 +184,7 @@ func main() {
minimalRotationTimeRatio,
gardenerCtrlReconciliationTimeout,
metrics,
).SetupWithManager(mgr); err != nil {
).SetupWithManager(mgr, gardenerClusterCtrlWorkersCnt); err != nil {
setupLog.Error(err, "unable to create controller", "controller", "GardenerCluster")
os.Exit(1)
}
Expand Down Expand Up @@ -229,7 +235,7 @@ func main() {
cfg,
)

if err = runtimeReconciler.SetupWithManager(mgr); err != nil {
if err = runtimeReconciler.SetupWithManager(mgr, runtimeCtrlWorkersCnt); err != nil {
setupLog.Error(err, "unable to setup controller with Manager", "controller", "Runtime")
os.Exit(1)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@ const (
clusterCRNameLabel = "operator.kyma-project.io/cluster-name"

rotationPeriodRatio = 0.95
numberOfWorkers = 25
)

// GardenerClusterController reconciles a GardenerCluster object
Expand Down Expand Up @@ -431,7 +430,7 @@ func (controller *GardenerClusterController) newSecret(cluster imv1.GardenerClus
}

// SetupWithManager sets up the controller with the Manager.
func (controller *GardenerClusterController) SetupWithManager(mgr ctrl.Manager) error {
func (controller *GardenerClusterController) SetupWithManager(mgr ctrl.Manager, numberOfWorkers int) error {
return ctrl.NewControllerManagedBy(mgr).
For(&imv1.GardenerCluster{}, builder.WithPredicates(predicate.Or(
predicate.LabelChangedPredicate{},
Expand Down
2 changes: 1 addition & 1 deletion internal/controller/kubeconfig/suite_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ var _ = BeforeSuite(func() {

Expect(gardenerClusterController).NotTo(BeNil())

err = gardenerClusterController.SetupWithManager(mgr)
err = gardenerClusterController.SetupWithManager(mgr, 1)
Expect(err).To(BeNil())

Expect(gardenerClusterController).NotTo(BeNil())
Expand Down
4 changes: 1 addition & 3 deletions internal/controller/runtime/runtime_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,6 @@ import (
"sigs.k8s.io/controller-runtime/pkg/predicate"
)

const numberOfWorkers = 25

// RuntimeReconciler reconciles a Runtime object
// nolint:revive
type RuntimeReconciler struct {
Expand Down Expand Up @@ -91,7 +89,7 @@ func NewRuntimeReconciler(mgr ctrl.Manager, shootClient client.Client, logger lo
}

// SetupWithManager sets up the controller with the Manager.
func (r *RuntimeReconciler) SetupWithManager(mgr ctrl.Manager) error {
func (r *RuntimeReconciler) SetupWithManager(mgr ctrl.Manager, numberOfWorkers int) error {
return ctrl.NewControllerManagedBy(mgr).
For(&imv1.Runtime{}).
WithOptions(controller.Options{MaxConcurrentReconciles: numberOfWorkers}).
Expand Down
2 changes: 1 addition & 1 deletion internal/controller/runtime/suite_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ var _ = BeforeSuite(func() {

runtimeReconciler = NewRuntimeReconciler(mgr, gardenerTestClient, logger, fsmCfg)
Expect(runtimeReconciler).NotTo(BeNil())
err = runtimeReconciler.SetupWithManager(mgr)
err = runtimeReconciler.SetupWithManager(mgr, 1)
Expect(err).To(BeNil())

//+kubebuilder:scaffold:scheme
Expand Down

0 comments on commit 9cb19cb

Please sign in to comment.