diff --git a/controllers/etcd_controller.go b/controllers/etcd_controller.go index 9709a4a05..979ea19b3 100644 --- a/controllers/etcd_controller.go +++ b/controllers/etcd_controller.go @@ -33,6 +33,7 @@ import ( "k8s.io/apimachinery/pkg/labels" "k8s.io/apimachinery/pkg/util/yaml" "sigs.k8s.io/controller-runtime/pkg/client" + "sigs.k8s.io/controller-runtime/pkg/controller" "sigs.k8s.io/controller-runtime/pkg/manager" druidv1alpha1 "github.com/gardener/etcd-druid/api/v1alpha1" @@ -988,9 +989,10 @@ func convertConditionsToEtcd(condition *appsv1.StatefulSetCondition) druidv1alph } // SetupWithManager sets up manager with a new controller and r as the reconcile.Reconciler -func (r *EtcdReconciler) SetupWithManager(mgr ctrl.Manager) error { - return ctrl.NewControllerManagedBy(mgr). - For(&druidv1alpha1.Etcd{}). +func (r *EtcdReconciler) SetupWithManager(mgr ctrl.Manager, workers int) error { + return ctrl.NewControllerManagedBy(mgr).WithOptions(controller.Options{ + MaxConcurrentReconciles: workers, + }).For(&druidv1alpha1.Etcd{}). Owns(&appsv1.StatefulSet{}). Complete(r) } diff --git a/main.go b/main.go index ffaadcd7e..65c4c365b 100644 --- a/main.go +++ b/main.go @@ -45,6 +45,8 @@ func init() { func main() { var metricsAddr string var enableLeaderElection bool + var workers int + flag.IntVar(&workers, "workers", 3, "Number of worker threads.") flag.StringVar(&metricsAddr, "metrics-addr", ":8080", "The address the metric endpoint binds to.") flag.BoolVar(&enableLeaderElection, "enable-leader-election", false, "Enable leader election for controller manager. Enabling this will ensure there is only one active controller manager.") @@ -67,7 +69,7 @@ func main() { setupLog.Error(err, "unable to initialize controller with image vector") os.Exit(1) } - err = ec.SetupWithManager(mgr) + err = ec.SetupWithManager(mgr, workers) if err != nil { setupLog.Error(err, "unable to create controller", "controller", "Etcd") os.Exit(1)