@@ -37,6 +37,7 @@ import (
3737 utilruntime "k8s.io/apimachinery/pkg/util/runtime"
3838 clientgoscheme "k8s.io/client-go/kubernetes/scheme"
3939 ctrl "sigs.k8s.io/controller-runtime"
40+ "sigs.k8s.io/controller-runtime/pkg/controller"
4041 "sigs.k8s.io/controller-runtime/pkg/healthz"
4142 "sigs.k8s.io/controller-runtime/pkg/manager"
4243
@@ -73,6 +74,8 @@ type managerOpts struct {
7374 WatchingNamespace string
7475 WatchFilterValue string
7576 CertDir string
77+
78+ CloudStackMachineConcurrency int
7679}
7780
7881func setFlags () * managerOpts {
@@ -117,6 +120,13 @@ func setFlags() *managerOpts {
117120 "webhook-cert-dir" ,
118121 "/tmp/k8s-webhook-server/serving-certs/" ,
119122 "Specify the directory where webhooks will get tls certificates." )
123+ flag .IntVar (
124+ & opts .CloudStackMachineConcurrency ,
125+ "cloudstackmachine-concurrency" ,
126+ 10 ,
127+ "Maximum concurrent reconciles for CloudStackMachine resources" ,
128+ )
129+
120130 return opts
121131}
122132
@@ -152,10 +162,11 @@ func main() {
152162 K8sClient : mgr .GetClient (),
153163 BaseLogger : ctrl .Log .WithName ("controllers" ),
154164 Recorder : mgr .GetEventRecorderFor ("capc-controller-manager" ),
155- Scheme : mgr .GetScheme ()}
165+ Scheme : mgr .GetScheme (),
166+ }
156167
157168 ctx := ctrl .SetupSignalHandler ()
158- setupReconcilers (ctx , base , mgr )
169+ setupReconcilers (ctx , base , * opts , mgr )
159170 infrav1b3 .K8sClient = base .K8sClient
160171
161172 // +kubebuilder:scaffold:builder
@@ -191,12 +202,12 @@ func main() {
191202 }
192203}
193204
194- func setupReconcilers (ctx context.Context , base utils.ReconcilerBase , mgr manager.Manager ) {
205+ func setupReconcilers (ctx context.Context , base utils.ReconcilerBase , opts managerOpts , mgr manager.Manager ) {
195206 if err := (& controllers.CloudStackClusterReconciler {ReconcilerBase : base }).SetupWithManager (ctx , mgr ); err != nil {
196207 setupLog .Error (err , "unable to create controller" , "controller" , "CloudStackCluster" )
197208 os .Exit (1 )
198209 }
199- if err := (& controllers.CloudStackMachineReconciler {ReconcilerBase : base }).SetupWithManager (mgr ); err != nil {
210+ if err := (& controllers.CloudStackMachineReconciler {ReconcilerBase : base }).SetupWithManager (mgr , controller. Options { MaxConcurrentReconciles : opts . CloudStackMachineConcurrency } ); err != nil {
200211 setupLog .Error (err , "unable to create controller" , "controller" , "CloudStackMachine" )
201212 os .Exit (1 )
202213 }
0 commit comments