diff --git a/go.mod b/go.mod index 220b9672..66d516f3 100644 --- a/go.mod +++ b/go.mod @@ -28,7 +28,7 @@ require ( github.com/fluxcd/pkg/cache v0.12.0 github.com/fluxcd/pkg/http/fetch v0.21.0 github.com/fluxcd/pkg/kustomize v1.24.0 - github.com/fluxcd/pkg/runtime v0.90.0 + github.com/fluxcd/pkg/runtime v0.91.0 github.com/fluxcd/pkg/ssa v0.61.0 github.com/fluxcd/pkg/tar v0.16.0 github.com/fluxcd/pkg/testserver v0.13.0 diff --git a/go.sum b/go.sum index 05e0fc15..e02c844f 100644 --- a/go.sum +++ b/go.sum @@ -206,8 +206,8 @@ github.com/fluxcd/pkg/http/fetch v0.21.0 h1:/vHWc+3BIk9q5HFA8khl0NEBb/XFXzZOqpnU github.com/fluxcd/pkg/http/fetch v0.21.0/go.mod h1:aFUPa2DLpUHE/dXkhIdaHakVIiZ6GVCWvp5tWkDKSEM= github.com/fluxcd/pkg/kustomize v1.24.0 h1:ckFB7hh9FpJA1Oy3bYl88p9On/zsZZTbwlLBgP6eUkA= github.com/fluxcd/pkg/kustomize v1.24.0/go.mod h1:cydG0vKpDuUaoP5STpKfxY3zqgzaARv5HsWDOFyt5nA= -github.com/fluxcd/pkg/runtime v0.90.0 h1:IONDsN9npJdWqbSAfsI8j10sXpgaLd6ywycKwp35Wwo= -github.com/fluxcd/pkg/runtime v0.90.0/go.mod h1:D/gUsaSpyw6Od2QEL7MELi5m+oUmwokuxUVZ+vKQxdo= +github.com/fluxcd/pkg/runtime v0.91.0 h1:Z92sOLsJXa+0RIi/vNl87zF5qnsBUdOb60d2a0b4Ulo= +github.com/fluxcd/pkg/runtime v0.91.0/go.mod h1:D/gUsaSpyw6Od2QEL7MELi5m+oUmwokuxUVZ+vKQxdo= github.com/fluxcd/pkg/sourceignore v0.15.0 h1:tB30fuk4jlB3UGlR7ppJguZ3zaJh1iwuTCEufs91jSM= github.com/fluxcd/pkg/sourceignore v0.15.0/go.mod h1:mZ9X6gNtNkq9ZsD35LebEYjePc7DRvB2JdowMNoj6IU= github.com/fluxcd/pkg/ssa v0.61.0 h1:GeueQfZVrjPLEzmEkq6gpFTBr1MDcqUihCQDf6AaIo8= diff --git a/internal/controller/kustomization_manager.go b/internal/controller/kustomization_manager.go index bd3652bb..3e358e3b 100644 --- a/internal/controller/kustomization_manager.go +++ b/internal/controller/kustomization_manager.go @@ -39,6 +39,7 @@ import ( // KustomizationReconcilerOptions contains options for the KustomizationReconciler. type KustomizationReconcilerOptions struct { RateLimiter workqueue.TypedRateLimiter[reconcile.Request] + WatchConfigs bool WatchConfigsPredicate predicate.Predicate WatchExternalArtifacts bool } @@ -147,18 +148,22 @@ func (r *KustomizationReconciler) SetupWithManager(ctx context.Context, mgr ctrl &sourcev1.Bucket{}, handler.EnqueueRequestsFromMapFunc(r.requestsForRevisionChangeOf(indexBucket)), builder.WithPredicates(SourceRevisionChangePredicate{}), - ). - WatchesMetadata( - &corev1.ConfigMap{}, - handler.EnqueueRequestsFromMapFunc(r.requestsForConfigDependency(indexConfigMap)), - builder.WithPredicates(predicate.ResourceVersionChangedPredicate{}, opts.WatchConfigsPredicate), - ). - WatchesMetadata( - &corev1.Secret{}, - handler.EnqueueRequestsFromMapFunc(r.requestsForConfigDependency(indexSecret)), - builder.WithPredicates(predicate.ResourceVersionChangedPredicate{}, opts.WatchConfigsPredicate), ) + if opts.WatchConfigs { + ctrlBuilder = ctrlBuilder. + WatchesMetadata( + &corev1.ConfigMap{}, + handler.EnqueueRequestsFromMapFunc(r.requestsForConfigDependency(indexConfigMap)), + builder.WithPredicates(predicate.ResourceVersionChangedPredicate{}, opts.WatchConfigsPredicate), + ). + WatchesMetadata( + &corev1.Secret{}, + handler.EnqueueRequestsFromMapFunc(r.requestsForConfigDependency(indexSecret)), + builder.WithPredicates(predicate.ResourceVersionChangedPredicate{}, opts.WatchConfigsPredicate), + ) + } + if opts.WatchExternalArtifacts { ctrlBuilder = ctrlBuilder.Watches( &sourcev1.ExternalArtifact{}, diff --git a/internal/features/features.go b/internal/features/features.go index 3ae5d021..15feee47 100644 --- a/internal/features/features.go +++ b/internal/features/features.go @@ -20,6 +20,7 @@ package features import ( "github.com/fluxcd/pkg/auth" + "github.com/fluxcd/pkg/runtime/controller" feathelper "github.com/fluxcd/pkg/runtime/features" ) @@ -95,6 +96,9 @@ var features = map[string]bool{ // CancelHealthCheckOnNewRevision // opt-in from v1.7 CancelHealthCheckOnNewRevision: false, + // DisableConfigWatchers + // opt-in from v1.7.3 + controller.FeatureGateDisableConfigWatchers: false, } func init() { diff --git a/main.go b/main.go index c1a7491e..84a43abb 100644 --- a/main.go +++ b/main.go @@ -312,6 +312,13 @@ func main() { } } + disableConfigWatchers, err := features.Enabled(runtimeCtrl.FeatureGateDisableConfigWatchers) + if err != nil { + setupLog.Error(err, "unable to check feature gate "+runtimeCtrl.FeatureGateDisableConfigWatchers) + os.Exit(1) + } + watchConfigs := !disableConfigWatchers + if err = (&controller.KustomizationReconciler{ AdditiveCELDependencyCheck: additiveCELDependencyCheck, AllowExternalArtifact: allowExternalArtifact, @@ -339,6 +346,7 @@ func main() { TokenCache: tokenCache, }).SetupWithManager(ctx, mgr, controller.KustomizationReconcilerOptions{ RateLimiter: runtimeCtrl.GetRateLimiter(rateLimiterOptions), + WatchConfigs: watchConfigs, WatchConfigsPredicate: watchConfigsPredicate, WatchExternalArtifacts: allowExternalArtifact, }); err != nil {