From 45c5120a5e316e6639e06e4d36f20d428770d36e Mon Sep 17 00:00:00 2001 From: rohan-019 Date: Wed, 24 Sep 2025 11:00:54 +0530 Subject: [PATCH] Fix: Ignore historical assigned replicas when clusters no longer meet constraints Signed-off-by: rohan-019 --- pkg/scheduler/core/spreadconstraint/group_clusters.go | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/pkg/scheduler/core/spreadconstraint/group_clusters.go b/pkg/scheduler/core/spreadconstraint/group_clusters.go index e6769e9a3b5c..50a3ffb1fa46 100644 --- a/pkg/scheduler/core/spreadconstraint/group_clusters.go +++ b/pkg/scheduler/core/spreadconstraint/group_clusters.go @@ -346,7 +346,10 @@ func (info *GroupClustersInfo) generateClustersInfo(clustersScore framework.Clus clustersReplicas := info.calAvailableReplicasFunc(clusters, rbSpec) for i, clustersReplica := range clustersReplicas { info.Clusters[i].AvailableReplicas = int64(clustersReplica.Replicas) - info.Clusters[i].AvailableReplicas += int64(rbSpec.AssignedReplicasForCluster(clustersReplica.Name)) + // Only add historical assignments if the cluster still meets constraints + if info.Clusters[i].AvailableReplicas > 0 { + info.Clusters[i].AvailableReplicas += int64(rbSpec.AssignedReplicasForCluster(clustersReplica.Name)) + } info.Clusters[i].AllocatableReplicas = clustersReplica.Replicas }