From a45b473fa1841660ca5002683b21a60fda3e5fca Mon Sep 17 00:00:00 2001 From: JuHyung Son Date: Wed, 28 Feb 2024 04:41:40 +0900 Subject: [PATCH] fix reconciler list only looping k8sgpt`s results (#357) Signed-off-by: JuHyung-Son Co-authored-by: Alex Jones --- controllers/k8sgpt_controller.go | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/controllers/k8sgpt_controller.go b/controllers/k8sgpt_controller.go index 0622f3f5..a7c51e64 100644 --- a/controllers/k8sgpt_controller.go +++ b/controllers/k8sgpt_controller.go @@ -311,7 +311,10 @@ func (r *K8sGPTReconciler) Reconcile(ctx context.Context, req ctrl.Request) (ctr // We emit when result Status is not historical // and when user configures a sink for the first time latestResultList := &corev1alpha1.ResultList{} - if err := r.List(ctx, latestResultList); err != nil { + if err := r.List(ctx, latestResultList, client.MatchingLabels(map[string]string{ + "k8sgpts.k8sgpt.ai/name": k8sgptConfig.Name, + "k8sgpts.k8sgpt.ai/namespace": k8sgptConfig.Namespace, + })); err != nil { return r.finishReconcile(err, false) } if len(latestResultList.Items) == 0 {