Skip to content

Commit

Permalink
fix: give operator controller a name
Browse files Browse the repository at this point in the history
Signed-off-by: Jan Fajerski <[email protected]>
  • Loading branch information
jan--f committed Nov 6, 2024
1 parent 5f2b6e5 commit 7fd8fab
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions pkg/controllers/operator/controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ func RegisterWithManager(mgr ctrl.Manager, namespace string) error {
rm := &resourceManager{
k8sClient: mgr.GetClient(),
scheme: mgr.GetScheme(),
logger: ctrl.Log.WithName("observability-operator"),
logger: ctrl.Log.WithName(name),
namespace: namespace,
}
// We only want to trigger a reconciliation when the generation
Expand All @@ -63,6 +63,7 @@ func RegisterWithManager(mgr ctrl.Manager, namespace string) error {
generationChanged := builder.WithPredicates(predicate.GenerationChangedPredicate{})

ctrl, err := ctrl.NewControllerManagedBy(mgr).
Named(name).
Owns(&monv1.ServiceMonitor{}, generationChanged).
Watches(
&corev1.Service{},
Expand Down Expand Up @@ -110,7 +111,7 @@ func (rm resourceManager) Reconcile(ctx context.Context, req ctrl.Request) (ctrl
func (rm resourceManager) operatorService(ctx context.Context, _ client.Object) []reconcile.Request {
var requests []reconcile.Request
op := &corev1.Service{}
err := rm.k8sClient.Get(ctx, types.NamespacedName{Name: "observability-operator", Namespace: rm.namespace}, op)
err := rm.k8sClient.Get(ctx, types.NamespacedName{Name: name, Namespace: rm.namespace}, op)
if errors.IsNotFound(err) {
return requests
}
Expand Down

0 comments on commit 7fd8fab

Please sign in to comment.