Skip to content

Commit 5874ab5

Browse files
sxdleonardoce
andcommitted
chore: add names to controllers (#5641)
Controller-runtime v0.19.0 errors when a controller manager detects multiple controllers with the same name; this is done to improve the clarity of the log messages. This patch adds a name for every controller in the operator, complying with this rule. For more information, see kubernetes-sigs/controller-runtime#2902 Closes #5640 Signed-off-by: Jonathan Gonzalez V. <jonathan.gonzalez@enterprisedb.com> Signed-off-by: Leonardo Cecchi <leonardo.cecchi@enterprisedb.com> Co-authored-by: Leonardo Cecchi <leonardo.cecchi@enterprisedb.com> (cherry picked from commit 6e28aa8)
1 parent a96b85f commit 5874ab5

File tree

7 files changed

+7
-0
lines changed

7 files changed

+7
-0
lines changed

internal/cmd/manager/instance/run/cmd.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -162,6 +162,7 @@ func runSubCommand(ctx context.Context, instance *postgres.Instance) error {
162162
reconciler := controller.NewInstanceReconciler(instance, mgr.GetClient(), metricsServer)
163163
err = ctrl.NewControllerManagedBy(mgr).
164164
For(&apiv1.Cluster{}).
165+
Named("instance-cluster").
165166
Complete(reconciler)
166167
if err != nil {
167168
setupLog.Error(err, "unable to create controller")

internal/controller/backup_controller.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -633,6 +633,7 @@ func (r *BackupReconciler) SetupWithManager(ctx context.Context, mgr ctrl.Manage
633633

634634
controllerBuilder := ctrl.NewControllerManagedBy(mgr).
635635
For(&apiv1.Backup{}).
636+
Named("backup").
636637
Watches(&apiv1.Cluster{},
637638
handler.EnqueueRequestsFromMapFunc(r.mapClustersToBackup()),
638639
builder.WithPredicates(clustersWithBackupPredicate),

internal/controller/cluster_controller.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -860,6 +860,7 @@ func (r *ClusterReconciler) SetupWithManager(ctx context.Context, mgr ctrl.Manag
860860

861861
return ctrl.NewControllerManagedBy(mgr).
862862
For(&apiv1.Cluster{}).
863+
Named("cluster").
863864
Owns(&corev1.Pod{}).
864865
Owns(&batchv1.Job{}).
865866
Owns(&corev1.Service{}).

internal/controller/pooler_controller.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,7 @@ func (r *PoolerReconciler) Reconcile(ctx context.Context, req ctrl.Request) (ctr
129129
func (r *PoolerReconciler) SetupWithManager(mgr ctrl.Manager) error {
130130
return ctrl.NewControllerManagedBy(mgr).
131131
For(&apiv1.Pooler{}).
132+
Named("pooler").
132133
Owns(&v1.Deployment{}).
133134
Owns(&corev1.Service{}).
134135
Owns(&corev1.ServiceAccount{}).

internal/controller/scheduledbackup_controller.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -353,5 +353,6 @@ func (r *ScheduledBackupReconciler) SetupWithManager(ctx context.Context, mgr ct
353353

354354
return ctrl.NewControllerManagedBy(mgr).
355355
For(&apiv1.ScheduledBackup{}).
356+
Named("scheduled-backup").
356357
Complete(r)
357358
}

internal/management/controller/externalservers/manager.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ func NewReconciler(instance *postgres.Instance, client client.Client) *Reconcile
4646
func (r *Reconciler) SetupWithManager(mgr ctrl.Manager) error {
4747
return ctrl.NewControllerManagedBy(mgr).
4848
For(&apiv1.Cluster{}).
49+
Named("instance-external-server").
4950
Complete(r)
5051
}
5152

internal/management/controller/tablespaces/manager.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ func NewTablespaceReconciler(instance *postgres.Instance, client client.Client)
4747
func (r *TablespaceReconciler) SetupWithManager(mgr ctrl.Manager) error {
4848
return ctrl.NewControllerManagedBy(mgr).
4949
For(&apiv1.Cluster{}).
50+
Named("instance-tablespaces").
5051
Complete(r)
5152
}
5253

0 commit comments

Comments
 (0)