From 34d9a38bac2b30d854806913e6b39d206324d10e Mon Sep 17 00:00:00 2001
From: phantomjinx
Date: Wed, 24 Jan 2024 10:47:25 +0000
Subject: [PATCH] HAWNG-418: Fixes handling of ingresses in route-supported
clusters
* deploy/role.yaml
* Gives operator service account permission to deal with ingresses
* hawtio_controller.go
* Only watch ingresses if routes are not supported since the former would
not be installed in a route-supported cluster
---
deploy/role.yaml | 7 ++++++-
pkg/controller/hawtio/hawtio_controller.go | 16 ++++++++--------
2 files changed, 14 insertions(+), 9 deletions(-)
diff --git a/deploy/role.yaml b/deploy/role.yaml
index 988d844b60..27692b0c6e 100644
--- a/deploy/role.yaml
+++ b/deploy/role.yaml
@@ -61,6 +61,12 @@ rules:
- routes/custom-host
verbs:
- create
+- apiGroups:
+ - networking.k8s.io
+ resources:
+ - ingresses
+ verbs:
+ - '*'
- apiGroups:
- template.openshift.io
resources:
@@ -84,4 +90,3 @@ rules:
- update
- create
- delete
-
diff --git a/pkg/controller/hawtio/hawtio_controller.go b/pkg/controller/hawtio/hawtio_controller.go
index 45153b685d..70f5e5ed2d 100644
--- a/pkg/controller/hawtio/hawtio_controller.go
+++ b/pkg/controller/hawtio/hawtio_controller.go
@@ -157,14 +157,14 @@ func add(mgr manager.Manager, r reconcile.Reconciler, routeSupport bool) error {
if err != nil {
return errs.Wrap(err, "Failed to create watch for Route resource")
}
- }
-
- err = c.Watch(&source.Kind{Type: &networkingv1.Ingress{}}, &handler.EnqueueRequestForOwner{
- IsController: true,
- OwnerType: &hawtiov1.Hawtio{},
- })
- if err != nil {
- return errs.Wrap(err, "Failed to create watch for Ingress resource")
+ } else {
+ err = c.Watch(&source.Kind{Type: &networkingv1.Ingress{}}, &handler.EnqueueRequestForOwner{
+ IsController: true,
+ OwnerType: &hawtiov1.Hawtio{},
+ })
+ if err != nil {
+ return errs.Wrap(err, "Failed to create watch for Ingress resource")
+ }
}
err = c.Watch(&source.Kind{Type: &appsv1.Deployment{}}, &handler.EnqueueRequestForOwner{