diff --git a/internal/controller/openlibertyapplication_controller.go b/internal/controller/openlibertyapplication_controller.go index 1515f7eb..998089c7 100644 --- a/internal/controller/openlibertyapplication_controller.go +++ b/internal/controller/openlibertyapplication_controller.go @@ -908,37 +908,43 @@ func (r *ReconcileOpenLiberty) SetupWithManager(mgr ctrl.Manager) error { }, } - b := ctrl.NewControllerManagedBy(mgr).For(&openlibertyv1.OpenLibertyApplication{}, builder.WithPredicates(pred)). - Owns(&corev1.Service{}, builder.WithPredicates(predSubResource)). - Owns(&corev1.Secret{}, builder.WithPredicates(predSubResource)). - Owns(&appsv1.Deployment{}, builder.WithPredicates(predSubResWithGenCheck)). - Owns(&appsv1.StatefulSet{}, builder.WithPredicates(predSubResWithGenCheck)). - Owns(&autoscalingv1.HorizontalPodAutoscaler{}, builder.WithPredicates(predSubResource)) - - ok, _ := r.IsGroupVersionSupported(routev1.SchemeGroupVersion.String(), "Route") - if ok { - b = b.Owns(&routev1.Route{}, builder.WithPredicates(predSubResource)) - } - ok, _ = r.IsGroupVersionSupported(networkingv1.SchemeGroupVersion.String(), "Ingress") - if ok { - b = b.Owns(&networkingv1.Ingress{}, builder.WithPredicates(predSubResource)) - } - ok, _ = r.IsGroupVersionSupported(servingv1.SchemeGroupVersion.String(), "Service") - if ok { - b = b.Owns(&servingv1.Service{}, builder.WithPredicates(predSubResource)) - } - ok, _ = r.IsGroupVersionSupported(prometheusv1.SchemeGroupVersion.String(), "ServiceMonitor") - if ok { - b = b.Owns(&prometheusv1.ServiceMonitor{}, builder.WithPredicates(predSubResource)) - } - ok, _ = r.IsGroupVersionSupported(imagev1.SchemeGroupVersion.String(), "ImageStream") - if ok { - b = b.Watches(&imagev1.ImageStream{}, &EnqueueRequestsForCustomIndexField{ - Matcher: &ImageStreamMatcher{ - Klient: mgr.GetClient(), - WatchNamespaces: watchNamespaces, - }, - }) + b := ctrl.NewControllerManagedBy(mgr).For(&openlibertyv1.OpenLibertyApplication{}, builder.WithPredicates(pred)) + + if !oputils.GetOperatorDisableWatches() { + b = b.Owns(&corev1.Service{}, builder.WithPredicates(predSubResource)). + Owns(&corev1.Secret{}, builder.WithPredicates(predSubResource)). + Owns(&appsv1.Deployment{}, builder.WithPredicates(predSubResWithGenCheck)). + Owns(&appsv1.StatefulSet{}, builder.WithPredicates(predSubResWithGenCheck)) + + if oputils.GetOperatorWatchHPA() { + b = b.Owns(&autoscalingv1.HorizontalPodAutoscaler{}, builder.WithPredicates(predSubResource)) + } + + ok, _ := r.IsGroupVersionSupported(routev1.SchemeGroupVersion.String(), "Route") + if ok { + b = b.Owns(&routev1.Route{}, builder.WithPredicates(predSubResource)) + } + ok, _ = r.IsGroupVersionSupported(networkingv1.SchemeGroupVersion.String(), "Ingress") + if ok { + b = b.Owns(&networkingv1.Ingress{}, builder.WithPredicates(predSubResource)) + } + ok, _ = r.IsGroupVersionSupported(servingv1.SchemeGroupVersion.String(), "Service") + if ok { + b = b.Owns(&servingv1.Service{}, builder.WithPredicates(predSubResource)) + } + ok, _ = r.IsGroupVersionSupported(prometheusv1.SchemeGroupVersion.String(), "ServiceMonitor") + if ok { + b = b.Owns(&prometheusv1.ServiceMonitor{}, builder.WithPredicates(predSubResource)) + } + ok, _ = r.IsGroupVersionSupported(imagev1.SchemeGroupVersion.String(), "ImageStream") + if ok { + b = b.Watches(&imagev1.ImageStream{}, &EnqueueRequestsForCustomIndexField{ + Matcher: &ImageStreamMatcher{ + Klient: mgr.GetClient(), + WatchNamespaces: watchNamespaces, + }, + }) + } } maxConcurrentReconciles := oputils.GetMaxConcurrentReconciles()