Skip to content

Commit b7c58e8

Browse files
committed
Make sure to log error in findObjectsForSrc()
It is hidden right now if there is an error in configured named fields and index. Lets log the error and return the current state of requests. With this the findObjectsForSrc() will exit with an hidden error like: ``` "error": "Index with name field:.spec.ksmTls.caBundleSecretName does not exist" ``` Signed-off-by: Martin Schuppert <[email protected]>
1 parent 50a00b9 commit b7c58e8

File tree

2 files changed

+8
-7
lines changed

2 files changed

+8
-7
lines changed

controllers/client/openstackclient_controller.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -524,11 +524,6 @@ func (r *OpenStackClientReconciler) SetupWithManager(
524524
handler.EnqueueRequestsFromMapFunc(r.findObjectsForSrc),
525525
builder.WithPredicates(predicate.ResourceVersionChangedPredicate{}),
526526
).
527-
Watches(
528-
&corev1.Secret{},
529-
handler.EnqueueRequestsFromMapFunc(r.findObjectsForSrc),
530-
builder.WithPredicates(predicate.ResourceVersionChangedPredicate{}),
531-
).
532527
Watches(
533528
// Reconcile all openstackclients when a MetricStorage changes.
534529
// This is needed to ensure the observability client is
@@ -542,6 +537,8 @@ func (r *OpenStackClientReconciler) SetupWithManager(
542537
func (r *OpenStackClientReconciler) findObjectsForSrc(ctx context.Context, src client.Object) []reconcile.Request {
543538
requests := []reconcile.Request{}
544539

540+
l := log.FromContext(context.Background()).WithName("Controllers").WithName("OpenStackClient")
541+
545542
for _, field := range allWatchFields {
546543
crList := &clientv1.OpenStackClientList{}
547544
listOps := &client.ListOptions{
@@ -550,10 +547,13 @@ func (r *OpenStackClientReconciler) findObjectsForSrc(ctx context.Context, src c
550547
}
551548
err := r.List(ctx, crList, listOps)
552549
if err != nil {
553-
return []reconcile.Request{}
550+
l.Error(err, fmt.Sprintf("listing %s for field: %s - %s", crList.GroupVersionKind().Kind, field, src.GetNamespace()))
551+
return requests
554552
}
555553

556554
for _, item := range crList.Items {
555+
l.Info(fmt.Sprintf("input source %s changed, reconcile: %s - %s", src.GetName(), item.GetName(), item.GetNamespace()))
556+
557557
requests = append(requests,
558558
reconcile.Request{
559559
NamespacedName: types.NamespacedName{

controllers/core/openstackcontrolplane_controller.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -615,7 +615,8 @@ func (r *OpenStackControlPlaneReconciler) findObjectsForSrc(ctx context.Context,
615615
}
616616
err := r.List(ctx, crList, listOps)
617617
if err != nil {
618-
return []reconcile.Request{}
618+
l.Error(err, fmt.Sprintf("listing %s for field: %s - %s", crList.GroupVersionKind().Kind, field, src.GetNamespace()))
619+
return requests
619620
}
620621

621622
for _, item := range crList.Items {

0 commit comments

Comments
 (0)