From 7f6b73b4dbd4817ec96bd501834db0ceacbbf84d Mon Sep 17 00:00:00 2001 From: MohammedAbdi Date: Fri, 14 Jun 2024 18:01:19 -0400 Subject: [PATCH] add co Signed-off-by: MohammedAbdi --- internal/controller/labelgroup_controller.go | 15 +++------------ internal/controller/resource_manager.go | 1 + 2 files changed, 4 insertions(+), 12 deletions(-) diff --git a/internal/controller/labelgroup_controller.go b/internal/controller/labelgroup_controller.go index c85480c..4dd607e 100644 --- a/internal/controller/labelgroup_controller.go +++ b/internal/controller/labelgroup_controller.go @@ -174,22 +174,13 @@ func (r *LabelGroupReconciler) Reconcile(ctx context.Context, req ctrl.Request) case susqlv1.Aggregating: r.Logger.V(5).Info("[Reconcile] Entered aggregating case.") // trace - // Get list of pods matching the label group - // podNames, namespaceNames, err := r.GetPodNamesMatchingLabels(ctx, labelGroup) - // r.Logger.V(5).Info(fmt.Sprintf("[Reconcile] podNames: %s", podNames)) // trace - // r.Logger.V(5).Info(fmt.Sprintf("[Reconcile] namespaceNames: %s", namespaceNames)) // trace // Get list of pods matching the label group and namespace podsInNamespace, err := r.filterPodsInNamespace(ctx, labelGroup.Namespace, labelGroup.Status.KubernetesLabels) - // var printPodNames []string - // for _, pod := range podsInNamespace { - // printPodNames = append(printPodNames, pod.Name) - // } - - r.Logger.V(5).Info(fmt.Sprintf("[Reconcile] LabelName: %s", labelGroup.Name)) - r.Logger.V(5).Info(fmt.Sprintf("[Reconcile] Namespace: %s", labelGroup.Namespace)) - r.Logger.V(5).Info(fmt.Sprintf("[Reconcile] podNamesinNamespace: [%s]", podsInNamespace)) + 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.") diff --git a/internal/controller/resource_manager.go b/internal/controller/resource_manager.go index 1769f03..b2ac13c 100644 --- a/internal/controller/resource_manager.go +++ b/internal/controller/resource_manager.go @@ -27,6 +27,7 @@ import ( "k8s.io/apimachinery/pkg/labels" ) +// Function to filter pods with matching labels from namespace label is defined func (r *LabelGroupReconciler) filterPodsInNamespace(ctx context.Context, namespace string, labelSelector map[string]string) ([]string, error) { // Initialize list options with label selector listOptions := &client.ListOptions{