Skip to content

Commit

Permalink
Remove HorizontalPodAutoscaler from owned and watched resources
Browse files Browse the repository at this point in the history
Signed-off-by: Leo Christy Jesuraj <[email protected]>
  • Loading branch information
leochr committed Dec 13, 2024
1 parent d6d1ab9 commit 39061cd
Showing 1 changed file with 37 additions and 31 deletions.
68 changes: 37 additions & 31 deletions internal/controller/openlibertyapplication_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down

0 comments on commit 39061cd

Please sign in to comment.