Skip to content

Commit 5669b7b

Browse files
authored
Merge pull request #1554 from fluxcd/backport-1553-to-release/v1.7.x
[release/v1.7.x] Add feature gate for disabling config watchers
2 parents 414a14e + b48eda9 commit 5669b7b

File tree

5 files changed

+30
-13
lines changed

5 files changed

+30
-13
lines changed

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ require (
2828
github.com/fluxcd/pkg/cache v0.12.0
2929
github.com/fluxcd/pkg/http/fetch v0.21.0
3030
github.com/fluxcd/pkg/kustomize v1.24.0
31-
github.com/fluxcd/pkg/runtime v0.90.0
31+
github.com/fluxcd/pkg/runtime v0.91.0
3232
github.com/fluxcd/pkg/ssa v0.61.0
3333
github.com/fluxcd/pkg/tar v0.16.0
3434
github.com/fluxcd/pkg/testserver v0.13.0

go.sum

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -206,8 +206,8 @@ github.com/fluxcd/pkg/http/fetch v0.21.0 h1:/vHWc+3BIk9q5HFA8khl0NEBb/XFXzZOqpnU
206206
github.com/fluxcd/pkg/http/fetch v0.21.0/go.mod h1:aFUPa2DLpUHE/dXkhIdaHakVIiZ6GVCWvp5tWkDKSEM=
207207
github.com/fluxcd/pkg/kustomize v1.24.0 h1:ckFB7hh9FpJA1Oy3bYl88p9On/zsZZTbwlLBgP6eUkA=
208208
github.com/fluxcd/pkg/kustomize v1.24.0/go.mod h1:cydG0vKpDuUaoP5STpKfxY3zqgzaARv5HsWDOFyt5nA=
209-
github.com/fluxcd/pkg/runtime v0.90.0 h1:IONDsN9npJdWqbSAfsI8j10sXpgaLd6ywycKwp35Wwo=
210-
github.com/fluxcd/pkg/runtime v0.90.0/go.mod h1:D/gUsaSpyw6Od2QEL7MELi5m+oUmwokuxUVZ+vKQxdo=
209+
github.com/fluxcd/pkg/runtime v0.91.0 h1:Z92sOLsJXa+0RIi/vNl87zF5qnsBUdOb60d2a0b4Ulo=
210+
github.com/fluxcd/pkg/runtime v0.91.0/go.mod h1:D/gUsaSpyw6Od2QEL7MELi5m+oUmwokuxUVZ+vKQxdo=
211211
github.com/fluxcd/pkg/sourceignore v0.15.0 h1:tB30fuk4jlB3UGlR7ppJguZ3zaJh1iwuTCEufs91jSM=
212212
github.com/fluxcd/pkg/sourceignore v0.15.0/go.mod h1:mZ9X6gNtNkq9ZsD35LebEYjePc7DRvB2JdowMNoj6IU=
213213
github.com/fluxcd/pkg/ssa v0.61.0 h1:GeueQfZVrjPLEzmEkq6gpFTBr1MDcqUihCQDf6AaIo8=

internal/controller/kustomization_manager.go

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ import (
3939
// KustomizationReconcilerOptions contains options for the KustomizationReconciler.
4040
type KustomizationReconcilerOptions struct {
4141
RateLimiter workqueue.TypedRateLimiter[reconcile.Request]
42+
WatchConfigs bool
4243
WatchConfigsPredicate predicate.Predicate
4344
WatchExternalArtifacts bool
4445
}
@@ -147,18 +148,22 @@ func (r *KustomizationReconciler) SetupWithManager(ctx context.Context, mgr ctrl
147148
&sourcev1.Bucket{},
148149
handler.EnqueueRequestsFromMapFunc(r.requestsForRevisionChangeOf(indexBucket)),
149150
builder.WithPredicates(SourceRevisionChangePredicate{}),
150-
).
151-
WatchesMetadata(
152-
&corev1.ConfigMap{},
153-
handler.EnqueueRequestsFromMapFunc(r.requestsForConfigDependency(indexConfigMap)),
154-
builder.WithPredicates(predicate.ResourceVersionChangedPredicate{}, opts.WatchConfigsPredicate),
155-
).
156-
WatchesMetadata(
157-
&corev1.Secret{},
158-
handler.EnqueueRequestsFromMapFunc(r.requestsForConfigDependency(indexSecret)),
159-
builder.WithPredicates(predicate.ResourceVersionChangedPredicate{}, opts.WatchConfigsPredicate),
160151
)
161152

153+
if opts.WatchConfigs {
154+
ctrlBuilder = ctrlBuilder.
155+
WatchesMetadata(
156+
&corev1.ConfigMap{},
157+
handler.EnqueueRequestsFromMapFunc(r.requestsForConfigDependency(indexConfigMap)),
158+
builder.WithPredicates(predicate.ResourceVersionChangedPredicate{}, opts.WatchConfigsPredicate),
159+
).
160+
WatchesMetadata(
161+
&corev1.Secret{},
162+
handler.EnqueueRequestsFromMapFunc(r.requestsForConfigDependency(indexSecret)),
163+
builder.WithPredicates(predicate.ResourceVersionChangedPredicate{}, opts.WatchConfigsPredicate),
164+
)
165+
}
166+
162167
if opts.WatchExternalArtifacts {
163168
ctrlBuilder = ctrlBuilder.Watches(
164169
&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

@@ -95,6 +96,9 @@ var features = map[string]bool{
9596
// CancelHealthCheckOnNewRevision
9697
// opt-in from v1.7
9798
CancelHealthCheckOnNewRevision: false,
99+
// DisableConfigWatchers
100+
// opt-in from v1.7.3
101+
controller.FeatureGateDisableConfigWatchers: false,
98102
}
99103

100104
func init() {

main.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -312,6 +312,13 @@ func main() {
312312
}
313313
}
314314

315+
disableConfigWatchers, err := features.Enabled(runtimeCtrl.FeatureGateDisableConfigWatchers)
316+
if err != nil {
317+
setupLog.Error(err, "unable to check feature gate "+runtimeCtrl.FeatureGateDisableConfigWatchers)
318+
os.Exit(1)
319+
}
320+
watchConfigs := !disableConfigWatchers
321+
315322
if err = (&controller.KustomizationReconciler{
316323
AdditiveCELDependencyCheck: additiveCELDependencyCheck,
317324
AllowExternalArtifact: allowExternalArtifact,
@@ -339,6 +346,7 @@ func main() {
339346
TokenCache: tokenCache,
340347
}).SetupWithManager(ctx, mgr, controller.KustomizationReconcilerOptions{
341348
RateLimiter: runtimeCtrl.GetRateLimiter(rateLimiterOptions),
349+
WatchConfigs: watchConfigs,
342350
WatchConfigsPredicate: watchConfigsPredicate,
343351
WatchExternalArtifacts: allowExternalArtifact,
344352
}); err != nil {

0 commit comments

Comments
 (0)