Skip to content

Commit 7145951

Browse files
DarrenDeng137Darren Deng
andauthored
Add default ratelimiter (#269)
Co-authored-by: Darren Deng <[email protected]>
1 parent 7b492c0 commit 7145951

File tree

1 file changed

+17
-4
lines changed

1 file changed

+17
-4
lines changed

cmd/manager/main.go

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ import (
4646
ctrlmgr "sigs.k8s.io/controller-runtime/pkg/manager"
4747

4848
"github.com/microsoft/cluster-api-provider-azurestackhci/controllers"
49+
"k8s.io/client-go/util/workqueue"
4950
)
5051

5152
var (
@@ -198,23 +199,32 @@ func main() {
198199
Client: mgr.GetClient(),
199200
Log: ctrl.Log.WithName("controllers").WithName("AzureStackHCIMachine"),
200201
Recorder: mgr.GetEventRecorderFor("azurestackhcimachine-reconciler"),
201-
}).SetupWithManager(mgr, controller.Options{MaxConcurrentReconciles: azureStackHCIMachineConcurrency}); err != nil {
202+
}).SetupWithManager(mgr, controller.Options{
203+
MaxConcurrentReconciles: azureStackHCIMachineConcurrency,
204+
RateLimiter: workqueue.DefaultControllerRateLimiter(),
205+
}); err != nil {
202206
setupLog.Error(err, "unable to create controller", "controller", "AzureStackHCIMachine")
203207
os.Exit(1)
204208
}
205209
if err = (&controllers.AzureStackHCIClusterReconciler{
206210
Client: mgr.GetClient(),
207211
Log: ctrl.Log.WithName("controllers").WithName("AzureStackHCICluster"),
208212
Recorder: mgr.GetEventRecorderFor("azurestackhcicluster-reconciler"),
209-
}).SetupWithManager(mgr, controller.Options{MaxConcurrentReconciles: azureStackHCIClusterConcurrency}); err != nil {
213+
}).SetupWithManager(mgr, controller.Options{
214+
MaxConcurrentReconciles: azureStackHCIClusterConcurrency,
215+
RateLimiter: workqueue.DefaultControllerRateLimiter(),
216+
}); err != nil {
210217
setupLog.Error(err, "unable to create controller", "controller", "AzureStackHCICluster")
211218
os.Exit(1)
212219
}
213220
if err = (&controllers.AzureStackHCILoadBalancerReconciler{
214221
Client: mgr.GetClient(),
215222
Log: ctrl.Log.WithName("controllers").WithName("AzureStackHCILoadBalancer"),
216223
Recorder: mgr.GetEventRecorderFor("azurestackhciloadbalancer-reconciler"),
217-
}).SetupWithManager(mgr, controller.Options{MaxConcurrentReconciles: azureStackHCIloadBalancerConcurrency}); err != nil {
224+
}).SetupWithManager(mgr, controller.Options{
225+
MaxConcurrentReconciles: azureStackHCIloadBalancerConcurrency,
226+
RateLimiter: workqueue.DefaultControllerRateLimiter(),
227+
}); err != nil {
218228
setupLog.Error(err, "unable to create controller", "controller", "AzureStackHCILoadBalancer")
219229
os.Exit(1)
220230
}
@@ -223,7 +233,10 @@ func main() {
223233
Log: ctrl.Log.WithName("controllers").WithName("AzureStackHCIVirtualMachine"),
224234
Scheme: mgr.GetScheme(),
225235
Recorder: mgr.GetEventRecorderFor("azurestackhcivirtualmachine-reconciler"),
226-
}).SetupWithManager(mgr, controller.Options{MaxConcurrentReconciles: azureStackHCIVirtualMachineConcurrency}); err != nil {
236+
}).SetupWithManager(mgr, controller.Options{
237+
MaxConcurrentReconciles: azureStackHCIVirtualMachineConcurrency,
238+
RateLimiter: workqueue.DefaultControllerRateLimiter(),
239+
}); err != nil {
227240
setupLog.Error(err, "unable to create controller", "controller", "AzureStackHCIVirtualMachine")
228241
os.Exit(1)
229242
}

0 commit comments

Comments
 (0)