Skip to content

Commit 64ee655

Browse files
authored
Merge pull request #465 from alexandermarston/463
2 parents 2214d57 + 42aaf61 commit 64ee655

File tree

2 files changed

+10
-1
lines changed

2 files changed

+10
-1
lines changed

controllers/helmrelease_controller.go

+6-1
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ import (
4545
"sigs.k8s.io/controller-runtime/pkg/controller/controllerutil"
4646
"sigs.k8s.io/controller-runtime/pkg/handler"
4747
"sigs.k8s.io/controller-runtime/pkg/predicate"
48+
"sigs.k8s.io/controller-runtime/pkg/ratelimiter"
4849
"sigs.k8s.io/controller-runtime/pkg/reconcile"
4950
"sigs.k8s.io/controller-runtime/pkg/source"
5051

@@ -118,7 +119,10 @@ func (r *HelmReleaseReconciler) SetupWithManager(mgr ctrl.Manager, opts HelmRele
118119
handler.EnqueueRequestsFromMapFunc(r.requestsForHelmChartChange),
119120
builder.WithPredicates(SourceRevisionChangePredicate{}),
120121
).
121-
WithOptions(controller.Options{MaxConcurrentReconciles: opts.MaxConcurrentReconciles}).
122+
WithOptions(controller.Options{
123+
MaxConcurrentReconciles: opts.MaxConcurrentReconciles,
124+
RateLimiter: opts.RateLimiter,
125+
}).
122126
Complete(r)
123127
}
124128

@@ -283,6 +287,7 @@ type HelmReleaseReconcilerOptions struct {
283287
MaxConcurrentReconciles int
284288
HTTPRetry int
285289
DependencyRequeueInterval time.Duration
290+
RateLimiter ratelimiter.RateLimiter
286291
}
287292

288293
func (r *HelmReleaseReconciler) reconcileRelease(ctx context.Context,

main.go

+4
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ import (
3232

3333
"github.com/fluxcd/pkg/runtime/acl"
3434
"github.com/fluxcd/pkg/runtime/client"
35+
helper "github.com/fluxcd/pkg/runtime/controller"
3536
"github.com/fluxcd/pkg/runtime/events"
3637
"github.com/fluxcd/pkg/runtime/leaderelection"
3738
"github.com/fluxcd/pkg/runtime/logger"
@@ -74,6 +75,7 @@ func main() {
7475
logOptions logger.Options
7576
aclOptions acl.Options
7677
leaderElectionOptions leaderelection.Options
78+
rateLimiterOptions helper.RateLimiterOptions
7779
defaultServiceAccount string
7880
)
7981

@@ -90,6 +92,7 @@ func main() {
9092
logOptions.BindFlags(flag.CommandLine)
9193
aclOptions.BindFlags(flag.CommandLine)
9294
leaderElectionOptions.BindFlags(flag.CommandLine)
95+
rateLimiterOptions.BindFlags(flag.CommandLine)
9396
kubeConfigOpts.BindFlags(flag.CommandLine)
9497
flag.Parse()
9598

@@ -148,6 +151,7 @@ func main() {
148151
MaxConcurrentReconciles: concurrent,
149152
DependencyRequeueInterval: requeueDependency,
150153
HTTPRetry: httpRetry,
154+
RateLimiter: helper.GetRateLimiter(rateLimiterOptions),
151155
}); err != nil {
152156
setupLog.Error(err, "unable to create controller", "controller", v2.HelmReleaseKind)
153157
os.Exit(1)

0 commit comments

Comments
 (0)