Skip to content

Commit a92514a

Browse files
Add flags for exponential back-off retry to Helm Controller
Signed-off-by: Alex Marston <alexander.marston@gmail.com>
1 parent cbe622f commit a92514a

File tree

4 files changed

+13
-4
lines changed

4 files changed

+13
-4
lines changed

controllers/helmrelease_controller.go

+6-1
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ import (
5757
"github.com/fluxcd/pkg/runtime/predicates"
5858
"github.com/fluxcd/pkg/runtime/transform"
5959
sourcev1 "github.com/fluxcd/source-controller/api/v1beta2"
60+
"sigs.k8s.io/controller-runtime/pkg/ratelimiter"
6061

6162
v2 "github.com/fluxcd/helm-controller/api/v2beta1"
6263
"github.com/fluxcd/helm-controller/internal/kube"
@@ -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,

go.mod

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ require (
99
github.com/fluxcd/pkg/apis/acl v0.0.3
1010
github.com/fluxcd/pkg/apis/kustomize v0.3.2
1111
github.com/fluxcd/pkg/apis/meta v0.12.1
12-
github.com/fluxcd/pkg/runtime v0.13.3
12+
github.com/fluxcd/pkg/runtime v0.14.0
1313
github.com/fluxcd/source-controller/api v0.22.3
1414
github.com/go-logr/logr v1.2.3
1515
github.com/hashicorp/go-retryablehttp v0.7.0

go.sum

+2-2
Original file line numberDiff line numberDiff line change
@@ -317,8 +317,8 @@ github.com/fluxcd/pkg/apis/kustomize v0.3.2 h1:ULoAwOOekHf5cy6mYIwL+K6v8/cfcNVVb
317317
github.com/fluxcd/pkg/apis/kustomize v0.3.2/go.mod h1:p8iAH5TeqMBnnxkkpCNNDvWYfKlNRx89a6WKOo+hJHA=
318318
github.com/fluxcd/pkg/apis/meta v0.12.1 h1:m5PfKAqbqWBvGp9+JRj1sv+xNkGsHwUVf+3rJ8wm6SE=
319319
github.com/fluxcd/pkg/apis/meta v0.12.1/go.mod h1:f8YVt70/KAhqzZ7xxhjvqyzKubOYx2pAbakb/FfCEg8=
320-
github.com/fluxcd/pkg/runtime v0.13.3 h1:k0Xun+RoEC/F6iuAPTA6rQb+I4B4oecBx6pOcodX11A=
321-
github.com/fluxcd/pkg/runtime v0.13.3/go.mod h1:dzWNKqFzFXeittbpFcJzR3cdC9CWlbzw+pNOgaVvF/0=
320+
github.com/fluxcd/pkg/runtime v0.14.0 h1:FsVIvkHb0T1XHPCmbOO5rLJuwvEXC1nQrlI9QrwEf/M=
321+
github.com/fluxcd/pkg/runtime v0.14.0/go.mod h1:dzWNKqFzFXeittbpFcJzR3cdC9CWlbzw+pNOgaVvF/0=
322322
github.com/fluxcd/source-controller/api v0.22.3 h1:HnpSnCtIytwSGSz2qu+GJwyZRmD5UXZL5oOQapiQOtk=
323323
github.com/fluxcd/source-controller/api v0.22.3/go.mod h1:Vb13q9Pq+1IW/sJUZn/RSb7IU5WT86Er6uCFPCFm9L4=
324324
github.com/form3tech-oss/jwt-go v3.2.2+incompatible/go.mod h1:pbq4aXjuKjdthFRnoDwaVPLA+WlJuPGy+QneDUgJi2k=

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)