From 4216e80daeff9a54f15e04d5f386838c51796ad8 Mon Sep 17 00:00:00 2001 From: ARRY7686 Date: Tue, 4 Nov 2025 16:57:42 +0530 Subject: [PATCH 1/2] Enhance logging for selected clusters in the generic scheduler. Added detailed cluster summaries to the log output when verbosity level is high, improving traceability during scheduling operations. --- pkg/scheduler/core/generic_scheduler.go | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/pkg/scheduler/core/generic_scheduler.go b/pkg/scheduler/core/generic_scheduler.go index 5f17ed0c3516..8fe95c04daca 100644 --- a/pkg/scheduler/core/generic_scheduler.go +++ b/pkg/scheduler/core/generic_scheduler.go @@ -20,6 +20,7 @@ import ( "context" "fmt" "time" + "strings" "k8s.io/klog/v2" @@ -99,8 +100,14 @@ func (g *genericScheduler) Schedule( if err != nil { return result, fmt.Errorf("failed to select clusters: %w", err) } - klog.V(4).Infof("Selected clusters: %v", selectedClusters) - + if klog.V(4).Enabled() { + var clusterSummaries []string + for _, c := range selectedClusters { + clusterSummaries = append(clusterSummaries, + fmt.Sprintf("%s(Score: %d, AvailableReplicas: %d)", c.Cluster.Name, c.Score, c.AvailableReplicas)) + } + klog.Infof("Selected clusters: [%s]", strings.Join(clusterSummaries, ", ")) + } clustersWithReplicas, err := g.assignReplicas(selectedClusters, spec, status) if err != nil { return result, fmt.Errorf("failed to assign replicas: %w", err) From 2581ec587170175117236ff9d44cfc46b9c75969 Mon Sep 17 00:00:00 2001 From: ARRY7686 Date: Thu, 6 Nov 2025 19:19:02 +0530 Subject: [PATCH 2/2] refactor: improve logging of selected clusters in the scheduler --- pkg/scheduler/core/generic_scheduler.go | 13 +++---------- 1 file changed, 3 insertions(+), 10 deletions(-) diff --git a/pkg/scheduler/core/generic_scheduler.go b/pkg/scheduler/core/generic_scheduler.go index 8fe95c04daca..53ad6db356ca 100644 --- a/pkg/scheduler/core/generic_scheduler.go +++ b/pkg/scheduler/core/generic_scheduler.go @@ -20,7 +20,6 @@ import ( "context" "fmt" "time" - "strings" "k8s.io/klog/v2" @@ -100,14 +99,8 @@ func (g *genericScheduler) Schedule( if err != nil { return result, fmt.Errorf("failed to select clusters: %w", err) } - if klog.V(4).Enabled() { - var clusterSummaries []string - for _, c := range selectedClusters { - clusterSummaries = append(clusterSummaries, - fmt.Sprintf("%s(Score: %d, AvailableReplicas: %d)", c.Cluster.Name, c.Score, c.AvailableReplicas)) - } - klog.Infof("Selected clusters: [%s]", strings.Join(clusterSummaries, ", ")) - } + klog.V(4).Infof("Selected clusters: %+v", selectedClusters) + clustersWithReplicas, err := g.assignReplicas(selectedClusters, spec, status) if err != nil { return result, fmt.Errorf("failed to assign replicas: %w", err) @@ -197,4 +190,4 @@ func (g *genericScheduler) selectClusters(clustersScore framework.ClusterScoreLi func (g *genericScheduler) assignReplicas(clusters []spreadconstraint.ClusterDetailInfo, spec *workv1alpha2.ResourceBindingSpec, status *workv1alpha2.ResourceBindingStatus) ([]workv1alpha2.TargetCluster, error) { return AssignReplicas(clusters, spec, status) -} +} \ No newline at end of file