diff --git a/internal/controller/labelgroup_controller.go b/internal/controller/labelgroup_controller.go index 4dd607e..81e9fbb 100644 --- a/internal/controller/labelgroup_controller.go +++ b/internal/controller/labelgroup_controller.go @@ -178,13 +178,17 @@ func (r *LabelGroupReconciler) Reconcile(ctx context.Context, req ctrl.Request) // Get list of pods matching the label group and namespace podsInNamespace, err := r.filterPodsInNamespace(ctx, labelGroup.Namespace, labelGroup.Status.KubernetesLabels) - r.Logger.V(5).Info(fmt.Sprintf("[Reconcile] LabelName: %s", labelGroup.Name)) // trace - r.Logger.V(5).Info(fmt.Sprintf("[Reconcile] Namespace: %s", labelGroup.Namespace)) // trace - r.Logger.V(5).Info(fmt.Sprintf("[Reconcile] podNamesinNamespace: %s", podsInNamespace)) // trace - if err != nil || len(podsInNamespace) == 0 { - r.Logger.V(0).Error(err, "[Reconcile] Couldn't get pods for the labels provided.") - r.Logger.V(5).Info(fmt.Sprintf("[Reconcile] labelGroup: %#v", labelGroup)) // trace + r.Logger.V(5).Info("[Reconcile] Unable to get podlist.") // trace + r.Logger.V(5).Info(fmt.Sprintf("[Reconcile] LabelName: %s", labelGroup.Name)) // trace + r.Logger.V(5).Info(fmt.Sprintf("[Reconcile] Namespace: %s", labelGroup.Namespace)) // trace + r.Logger.V(5).Info(fmt.Sprintf("[Reconcile] KubernetesLabels: %#v", labelGroup.Status.KubernetesLabels)) // trace + r.Logger.V(5).Info(fmt.Sprintf("[Reconcile] podNamesinNamespace: %s", podsInNamespace)) // trace + r.Logger.V(5).Info(fmt.Sprintf("[Reconcile] ctx: %#v", ctx)) // trace + if err != nil { + r.Logger.V(0).Error(err, "[Reconcile] ERROR: Couldn't get pods for the labels provided.") + } + return ctrl.Result{}, err } diff --git a/internal/controller/resource_manager.go b/internal/controller/resource_manager.go index b2ac13c..c51baa9 100644 --- a/internal/controller/resource_manager.go +++ b/internal/controller/resource_manager.go @@ -38,6 +38,11 @@ func (r *LabelGroupReconciler) filterPodsInNamespace(ctx context.Context, namesp // List pods in the specified namespace with label selector applied var podList v1.PodList if err := r.Client.List(ctx, &podList, listOptions); err != nil { + r.Logger.V(5).Info(fmt.Sprintf("[filterPodsInNamespace] labelSelector: %#v", labelSelector)) + r.Logger.V(5).Info(fmt.Sprintf("[filterPodsInNamespace] ctx: %#v", ctx)) + r.Logger.V(5).Info(fmt.Sprintf("[filterPodsInNamespace] podList: %#v", podList)) + r.Logger.V(5).Info(fmt.Sprintf("[filterPodsInNamespace] listOptions: %#v", listOptions)) + r.Logger.V(0).Error(err, "[filterPodsInNamespace] List Error:") return nil, err } @@ -45,17 +50,18 @@ func (r *LabelGroupReconciler) filterPodsInNamespace(ctx context.Context, namesp for _, pod := range podList.Items { podNames = append(podNames, pod.Name) } + return podNames, nil } // Functions to get data from the cluster func (r *LabelGroupReconciler) GetPodNamesMatchingLabels(ctx context.Context, labelGroup *susqlv1.LabelGroup) ([]string, []string, error) { pods := &v1.PodList{} - r.Logger.V(5).Info(fmt.Sprintf("[GetPodNamesMatchingLabels] pods: %#v", pods)) - - r.Logger.V(5).Info(fmt.Sprintf("[LabelGroup] pods: %#v", labelGroup)) if err := r.List(ctx, pods, client.UnsafeDisableDeepCopy, (client.MatchingLabels)(labelGroup.Status.KubernetesLabels)); err != nil { + r.Logger.V(5).Info(fmt.Sprintf("[GetPodNamesMatchingLabels] pods: %#v", pods)) + r.Logger.V(5).Info(fmt.Sprintf("[GetPodNamesMatchingLabels] labelgroup: %#v", labelGroup)) + r.Logger.V(0).Error(err, "[GetPodNamesMatchingLabels] List Error:") return nil, nil, err }