fix bug of #2447: when replicaDivisionPreference is Weighted and WeightPreference is nil

Signed-off-by: changzhen <changzhen5@huawei.com>
This commit is contained in:
changzhen 2022-08-30 21:48:05 +08:00
parent 102ac7de39
commit 8b4eb7b310
1 changed files with 2 additions and 1 deletions

View File

@ -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
}