@@ -25,6 +25,7 @@ import (
25
25
"github.com/application-stacks/runtime-component-operator/common"
26
26
"github.com/pkg/errors"
27
27
28
+ kcontroller "sigs.k8s.io/controller-runtime/pkg/controller"
28
29
"sigs.k8s.io/controller-runtime/pkg/event"
29
30
"sigs.k8s.io/controller-runtime/pkg/reconcile"
30
31
@@ -36,7 +37,6 @@ import (
36
37
"github.com/go-logr/logr"
37
38
38
39
ctrl "sigs.k8s.io/controller-runtime"
39
- kcontroller "sigs.k8s.io/controller-runtime/pkg/controller"
40
40
41
41
appstacksv1 "github.com/application-stacks/runtime-component-operator/api/v1"
42
42
imagev1 "github.com/openshift/api/image/v1"
@@ -616,44 +616,50 @@ func (r *RuntimeComponentReconciler) SetupWithManager(mgr ctrl.Manager) error {
616
616
},
617
617
}
618
618
619
- maxConcurrentReconciles := appstacksutils . GetMaxConcurrentReconciles ( )
619
+ b := ctrl . NewControllerManagedBy ( mgr ). For ( & appstacksv1. RuntimeComponent {}, builder . WithPredicates ( pred ) )
620
620
621
- b := ctrl .NewControllerManagedBy (mgr ).For (& appstacksv1.RuntimeComponent {}, builder .WithPredicates (pred )).
622
- Owns (& corev1.Service {}, builder .WithPredicates (predSubResource )).
623
- Owns (& corev1.Secret {}, builder .WithPredicates (predSubResource )).
624
- Owns (& appsv1.Deployment {}, builder .WithPredicates (predSubResWithGenCheck )).
625
- Owns (& appsv1.StatefulSet {}, builder .WithPredicates (predSubResWithGenCheck )).
626
- Owns (& autoscalingv1.HorizontalPodAutoscaler {}, builder .WithPredicates (predSubResource )).
627
- WithOptions (kcontroller.Options {
628
- MaxConcurrentReconciles : maxConcurrentReconciles ,
629
- })
621
+ if ! appstacksutils .GetOperatorDisableWatches () {
622
+ b = b .Owns (& corev1.Service {}, builder .WithPredicates (predSubResource )).
623
+ Owns (& corev1.Secret {}, builder .WithPredicates (predSubResource )).
624
+ Owns (& appsv1.Deployment {}, builder .WithPredicates (predSubResWithGenCheck )).
625
+ Owns (& appsv1.StatefulSet {}, builder .WithPredicates (predSubResWithGenCheck ))
630
626
631
- ok , _ := r .IsGroupVersionSupported (routev1 .SchemeGroupVersion .String (), "Route" )
632
- if ok {
633
- b = b .Owns (& routev1.Route {}, builder .WithPredicates (predSubResource ))
634
- }
635
- ok , _ = r .IsGroupVersionSupported (networkingv1 .SchemeGroupVersion .String (), "Ingress" )
636
- if ok {
637
- b = b .Owns (& networkingv1.Ingress {}, builder .WithPredicates (predSubResource ))
638
- }
639
- ok , _ = r .IsGroupVersionSupported (servingv1 .SchemeGroupVersion .String (), "Service" )
640
- if ok {
641
- b = b .Owns (& servingv1.Service {}, builder .WithPredicates (predSubResource ))
642
- }
643
- ok , _ = r .IsGroupVersionSupported (prometheusv1 .SchemeGroupVersion .String (), "ServiceMonitor" )
644
- if ok {
645
- b = b .Owns (& prometheusv1.ServiceMonitor {}, builder .WithPredicates (predSubResource ))
646
- }
647
- ok , _ = r .IsGroupVersionSupported (imagev1 .SchemeGroupVersion .String (), "ImageStream" )
648
- if ok {
649
- b = b .Watches (& imagev1.ImageStream {}, & EnqueueRequestsForCustomIndexField {
650
- Matcher : & ImageStreamMatcher {
651
- Klient : mgr .GetClient (),
652
- WatchNamespaces : watchNamespaces ,
653
- },
654
- })
627
+ if appstacksutils .GetOperatorWatchHPA () {
628
+ b = b .Owns (& autoscalingv1.HorizontalPodAutoscaler {}, builder .WithPredicates (predSubResource ))
629
+ }
630
+
631
+ ok , _ := r .IsGroupVersionSupported (routev1 .SchemeGroupVersion .String (), "Route" )
632
+ if ok {
633
+ b = b .Owns (& routev1.Route {}, builder .WithPredicates (predSubResource ))
634
+ }
635
+ ok , _ = r .IsGroupVersionSupported (networkingv1 .SchemeGroupVersion .String (), "Ingress" )
636
+ if ok {
637
+ b = b .Owns (& networkingv1.Ingress {}, builder .WithPredicates (predSubResource ))
638
+ }
639
+ ok , _ = r .IsGroupVersionSupported (servingv1 .SchemeGroupVersion .String (), "Service" )
640
+ if ok {
641
+ b = b .Owns (& servingv1.Service {}, builder .WithPredicates (predSubResource ))
642
+ }
643
+ ok , _ = r .IsGroupVersionSupported (prometheusv1 .SchemeGroupVersion .String (), "ServiceMonitor" )
644
+ if ok {
645
+ b = b .Owns (& prometheusv1.ServiceMonitor {}, builder .WithPredicates (predSubResource ))
646
+ }
647
+ ok , _ = r .IsGroupVersionSupported (imagev1 .SchemeGroupVersion .String (), "ImageStream" )
648
+ if ok {
649
+ b = b .Watches (& imagev1.ImageStream {}, & EnqueueRequestsForCustomIndexField {
650
+ Matcher : & ImageStreamMatcher {
651
+ Klient : mgr .GetClient (),
652
+ WatchNamespaces : watchNamespaces ,
653
+ },
654
+ })
655
+ }
655
656
}
656
- return b .Complete (r )
657
+
658
+ maxConcurrentReconciles := appstacksutils .GetMaxConcurrentReconciles ()
659
+
660
+ return b .WithOptions (kcontroller.Options {
661
+ MaxConcurrentReconciles : maxConcurrentReconciles ,
662
+ }).Complete (r )
657
663
}
658
664
659
665
func getMonitoringEnabledLabelName (ba common.BaseComponent ) string {
0 commit comments