Skip to content

Commit

Permalink
Merge pull request #284 from stuggi/improve_index
Browse files Browse the repository at this point in the history
Make sure to log error in findObjectsForSrc()
  • Loading branch information
openshift-merge-bot[bot] authored Oct 10, 2024
2 parents d1d7314 + b3bf87d commit 1da98a9
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 19 deletions.
22 changes: 6 additions & 16 deletions controllers/instanceha/instanceha_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -540,27 +540,14 @@ func (r *Reconciler) SetupWithManager(mgr ctrl.Manager) error {
handler.EnqueueRequestsFromMapFunc(r.findObjectsForSrc),
builder.WithPredicates(predicate.ResourceVersionChangedPredicate{}),
).
Watches(
&corev1.Secret{},
handler.EnqueueRequestsFromMapFunc(r.findObjectsForSrc),
builder.WithPredicates(predicate.ResourceVersionChangedPredicate{}),
).
Watches(
&corev1.Secret{},
handler.EnqueueRequestsFromMapFunc(r.findObjectsForSrc),
builder.WithPredicates(predicate.ResourceVersionChangedPredicate{}),
).
Watches(
&corev1.ConfigMap{},
handler.EnqueueRequestsFromMapFunc(r.findObjectsForSrc),
builder.WithPredicates(predicate.ResourceVersionChangedPredicate{}),
).
Complete(r)
}

func (r *Reconciler) findObjectsForSrc(ctx context.Context, src client.Object) []reconcile.Request {
requests := []reconcile.Request{}

l := log.FromContext(context.Background()).WithName("Controllers").WithName("InstanceHa")

for _, field := range allWatchFields {
crList := &instancehav1.InstanceHaList{}
listOps := &client.ListOptions{
Expand All @@ -569,10 +556,13 @@ func (r *Reconciler) findObjectsForSrc(ctx context.Context, src client.Object) [
}
err := r.List(ctx, crList, listOps)
if err != nil {
return []reconcile.Request{}
l.Error(err, fmt.Sprintf("listing %s for field: %s - %s", crList.GroupVersionKind().Kind, field, src.GetNamespace()))
return requests
}

for _, item := range crList.Items {
l.Info(fmt.Sprintf("input source %s changed, reconcile: %s - %s", src.GetName(), item.GetName(), item.GetNamespace()))

requests = append(requests,
reconcile.Request{
NamespacedName: types.NamespacedName{
Expand Down
7 changes: 6 additions & 1 deletion controllers/memcached/memcached_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -468,6 +468,8 @@ func (r *Reconciler) SetupWithManager(mgr ctrl.Manager) error {
func (r *Reconciler) findObjectsForSrc(_ context.Context, src client.Object) []reconcile.Request {
requests := []reconcile.Request{}

l := log.FromContext(context.Background()).WithName("Controllers").WithName("Memcached")

for _, field := range allWatchFields {
crList := &memcachedv1.MemcachedList{}
listOps := &client.ListOptions{
Expand All @@ -476,10 +478,13 @@ func (r *Reconciler) findObjectsForSrc(_ context.Context, src client.Object) []r
}
err := r.List(context.TODO(), crList, listOps)
if err != nil {
return []reconcile.Request{}
l.Error(err, fmt.Sprintf("listing %s for field: %s - %s", crList.GroupVersionKind().Kind, field, src.GetNamespace()))
return requests
}

for _, item := range crList.Items {
l.Info(fmt.Sprintf("input source %s changed, reconcile: %s - %s", src.GetName(), item.GetName(), item.GetNamespace()))

requests = append(requests,
reconcile.Request{
NamespacedName: types.NamespacedName{
Expand Down
7 changes: 6 additions & 1 deletion controllers/rabbitmq/transporturl_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -368,6 +368,8 @@ func (r *TransportURLReconciler) SetupWithManager(mgr ctrl.Manager) error {
func (r *TransportURLReconciler) findObjectsForSrc(ctx context.Context, src client.Object) []reconcile.Request {
requests := []reconcile.Request{}

l := log.FromContext(context.Background()).WithName("Controllers").WithName("TransportURL")

for _, field := range allWatchFields {
crList := &rabbitmqv1.TransportURLList{}
listOps := &client.ListOptions{
Expand All @@ -376,10 +378,13 @@ func (r *TransportURLReconciler) findObjectsForSrc(ctx context.Context, src clie
}
err := r.List(ctx, crList, listOps)
if err != nil {
return []reconcile.Request{}
l.Error(err, fmt.Sprintf("listing %s for field: %s - %s", crList.GroupVersionKind().Kind, field, src.GetNamespace()))
return requests
}

for _, item := range crList.Items {
l.Info(fmt.Sprintf("input source %s changed, reconcile: %s - %s", src.GetName(), item.GetName(), item.GetNamespace()))

requests = append(requests,
reconcile.Request{
NamespacedName: types.NamespacedName{
Expand Down
7 changes: 6 additions & 1 deletion controllers/redis/redis_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -465,6 +465,8 @@ func (r *Reconciler) SetupWithManager(mgr ctrl.Manager) error {
func (r *Reconciler) findObjectsForSrc(ctx context.Context, src client.Object) []reconcile.Request {
requests := []reconcile.Request{}

l := log.FromContext(context.Background()).WithName("Controllers").WithName("Redis")

for _, field := range allWatchFields {
crList := &redisv1.RedisList{}
listOps := &client.ListOptions{
Expand All @@ -473,10 +475,13 @@ func (r *Reconciler) findObjectsForSrc(ctx context.Context, src client.Object) [
}
err := r.List(ctx, crList, listOps)
if err != nil {
return []reconcile.Request{}
l.Error(err, fmt.Sprintf("listing %s for field: %s - %s", crList.GroupVersionKind().Kind, field, src.GetNamespace()))
return requests
}

for _, item := range crList.Items {
l.Info(fmt.Sprintf("input source %s changed, reconcile: %s - %s", src.GetName(), item.GetName(), item.GetNamespace()))

requests = append(requests,
reconcile.Request{
NamespacedName: types.NamespacedName{
Expand Down

0 comments on commit 1da98a9

Please sign in to comment.