Skip to content

Commit 1c7b8cf

Browse files
authored
Merge pull request #1353 from fluxcd/gate-watch-config
Add feature gate for disabling config watchers
2 parents e554857 + 0d78b8d commit 1c7b8cf

File tree

5 files changed

+32
-15
lines changed

5 files changed

+32
-15
lines changed

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ require (
2525
github.com/fluxcd/pkg/auth v0.33.0
2626
github.com/fluxcd/pkg/cache v0.12.0
2727
github.com/fluxcd/pkg/chartutil v1.17.0
28-
github.com/fluxcd/pkg/runtime v0.90.0
28+
github.com/fluxcd/pkg/runtime v0.91.0
2929
github.com/fluxcd/pkg/ssa v0.61.0
3030
github.com/fluxcd/pkg/testserver v0.13.0
3131
github.com/fluxcd/source-controller/api v1.7.2

go.sum

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -160,8 +160,8 @@ github.com/fluxcd/pkg/cache v0.12.0 h1:mabABT3jIfuo84VbIW+qvfqMZ7PbM5tXQgQvA2uo2
160160
github.com/fluxcd/pkg/cache v0.12.0/go.mod h1:HL/9cgBmwCdKIr3JH57rxrGdb7rOgX5Z1eJlHsaV1vE=
161161
github.com/fluxcd/pkg/chartutil v1.17.0 h1:UiSBRujE2/Qo8qrv8F3XGEMI5YANS0PpbG/r+CxKUW0=
162162
github.com/fluxcd/pkg/chartutil v1.17.0/go.mod h1:Zt8EolwLyYj0689Ivk9cL4mYZlR3BBi/XVGyeGmPVlE=
163-
github.com/fluxcd/pkg/runtime v0.90.0 h1:IONDsN9npJdWqbSAfsI8j10sXpgaLd6ywycKwp35Wwo=
164-
github.com/fluxcd/pkg/runtime v0.90.0/go.mod h1:D/gUsaSpyw6Od2QEL7MELi5m+oUmwokuxUVZ+vKQxdo=
163+
github.com/fluxcd/pkg/runtime v0.91.0 h1:Z92sOLsJXa+0RIi/vNl87zF5qnsBUdOb60d2a0b4Ulo=
164+
github.com/fluxcd/pkg/runtime v0.91.0/go.mod h1:D/gUsaSpyw6Od2QEL7MELi5m+oUmwokuxUVZ+vKQxdo=
165165
github.com/fluxcd/pkg/ssa v0.61.0 h1:GeueQfZVrjPLEzmEkq6gpFTBr1MDcqUihCQDf6AaIo8=
166166
github.com/fluxcd/pkg/ssa v0.61.0/go.mod h1:PNRlgihYbmlQU5gzsB14nrsNMbtACNanBnKhLCWmeX8=
167167
github.com/fluxcd/pkg/testserver v0.13.0 h1:xEpBcEYtD7bwvZ+i0ZmChxKkDo/wfQEV3xmnzVybSSg=

internal/controller/helmrelease_manager.go

Lines changed: 16 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,9 @@ import (
3838

3939
type HelmReleaseReconcilerOptions struct {
4040
RateLimiter workqueue.TypedRateLimiter[reconcile.Request]
41-
WatchExternalArtifacts bool
41+
WatchConfigs bool
4242
WatchConfigsPredicate predicate.Predicate
43+
WatchExternalArtifacts bool
4344
}
4445

4546
func (r *HelmReleaseReconciler) SetupWithManager(ctx context.Context, mgr ctrl.Manager, opts HelmReleaseReconcilerOptions) error {
@@ -127,18 +128,22 @@ func (r *HelmReleaseReconciler) SetupWithManager(ctx context.Context, mgr ctrl.M
127128
&sourcev1.OCIRepository{},
128129
handler.EnqueueRequestsFromMapFunc(r.requestsForOCIRepositoryChange),
129130
builder.WithPredicates(intpredicates.SourceRevisionChangePredicate{}),
130-
).
131-
WatchesMetadata(
132-
&corev1.ConfigMap{},
133-
handler.EnqueueRequestsFromMapFunc(r.requestsForConfigDependency(indexConfigMap)),
134-
builder.WithPredicates(predicate.ResourceVersionChangedPredicate{}, opts.WatchConfigsPredicate),
135-
).
136-
WatchesMetadata(
137-
&corev1.Secret{},
138-
handler.EnqueueRequestsFromMapFunc(r.requestsForConfigDependency(indexSecret)),
139-
builder.WithPredicates(predicate.ResourceVersionChangedPredicate{}, opts.WatchConfigsPredicate),
140131
)
141132

133+
if opts.WatchConfigs {
134+
ctrlBuilder = ctrlBuilder.
135+
WatchesMetadata(
136+
&corev1.ConfigMap{},
137+
handler.EnqueueRequestsFromMapFunc(r.requestsForConfigDependency(indexConfigMap)),
138+
builder.WithPredicates(predicate.ResourceVersionChangedPredicate{}, opts.WatchConfigsPredicate),
139+
).
140+
WatchesMetadata(
141+
&corev1.Secret{},
142+
handler.EnqueueRequestsFromMapFunc(r.requestsForConfigDependency(indexSecret)),
143+
builder.WithPredicates(predicate.ResourceVersionChangedPredicate{}, opts.WatchConfigsPredicate),
144+
)
145+
}
146+
142147
if opts.WatchExternalArtifacts {
143148
ctrlBuilder = ctrlBuilder.Watches(
144149
&sourcev1.ExternalArtifact{},

internal/features/features.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ package features
2020

2121
import (
2222
"github.com/fluxcd/pkg/auth"
23+
"github.com/fluxcd/pkg/runtime/controller"
2324
feathelper "github.com/fluxcd/pkg/runtime/features"
2425
)
2526

@@ -106,6 +107,9 @@ var features = map[string]bool{
106107
// ExternalArtifact
107108
// opt-in from v1.4.0
108109
ExternalArtifact: false,
110+
// DisableConfigWatchers
111+
// opt-in from v1.4.4
112+
controller.FeatureGateDisableConfigWatchers: false,
109113
}
110114

111115
func init() {

main.go

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -332,6 +332,13 @@ func main() {
332332
os.Exit(1)
333333
}
334334

335+
disableConfigWatchers, err := features.Enabled(helper.FeatureGateDisableConfigWatchers)
336+
if err != nil {
337+
setupLog.Error(err, "unable to check feature gate "+helper.FeatureGateDisableConfigWatchers)
338+
os.Exit(1)
339+
}
340+
watchConfigs := !disableConfigWatchers
341+
335342
if err = (&controller.HelmReleaseReconciler{
336343
Client: mgr.GetClient(),
337344
APIReader: mgr.GetAPIReader(),
@@ -349,8 +356,9 @@ func main() {
349356
AllowExternalArtifact: allowExternalArtifact,
350357
}).SetupWithManager(ctx, mgr, controller.HelmReleaseReconcilerOptions{
351358
RateLimiter: helper.GetRateLimiter(rateLimiterOptions),
352-
WatchExternalArtifacts: allowExternalArtifact,
359+
WatchConfigs: watchConfigs,
353360
WatchConfigsPredicate: watchConfigsPredicate,
361+
WatchExternalArtifacts: allowExternalArtifact,
354362
}); err != nil {
355363
setupLog.Error(err, "unable to create controller", "controller", v2.HelmReleaseKind)
356364
os.Exit(1)

0 commit comments

Comments
 (0)