From 8b4eb7b310f6ea3db7c3a11bf574e1ec83e913a9 Mon Sep 17 00:00:00 2001 From: changzhen Date: Tue, 30 Aug 2022 21:48:05 +0800 Subject: [PATCH] fix bug of #2447: when replicaDivisionPreference is Weighted and WeightPreference is nil Signed-off-by: changzhen --- pkg/scheduler/core/spreadconstraint/group_clusters.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/pkg/scheduler/core/spreadconstraint/group_clusters.go b/pkg/scheduler/core/spreadconstraint/group_clusters.go index 27c24a434..e9db3818e 100644 --- a/pkg/scheduler/core/spreadconstraint/group_clusters.go +++ b/pkg/scheduler/core/spreadconstraint/group_clusters.go @@ -245,7 +245,8 @@ func isTopologyIgnored(placement *policyv1alpha1.Placement) bool { // If the replica division preference is 'static weighted', ignore the declaration specified by spread constraints. if strategy != nil && strategy.ReplicaSchedulingType == policyv1alpha1.ReplicaSchedulingTypeDivided && strategy.ReplicaDivisionPreference == policyv1alpha1.ReplicaDivisionPreferenceWeighted && - (len(strategy.WeightPreference.StaticWeightList) != 0 && strategy.WeightPreference.DynamicWeight == "") { + (strategy.WeightPreference == nil || + len(strategy.WeightPreference.StaticWeightList) != 0 && strategy.WeightPreference.DynamicWeight == "") { return true }