Skip to content

Commit 4886218

Browse files
committed
Fix a preemption bug when pods are matched by pdb.Status.DisruptedPods
1 parent dc0122c commit 4886218

File tree

1 file changed

+6
-7
lines changed

1 file changed

+6
-7
lines changed

pkg/scheduler/core/generic_scheduler.go

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -936,15 +936,14 @@ func filterPodsWithPDBViolation(pods []*v1.Pod, pdbs []*policy.PodDisruptionBudg
936936
if selector.Empty() || !selector.Matches(labels.Set(pod.Labels)) {
937937
continue
938938
}
939+
// Only decrement the matched pdb when it's not in its <DisruptedPods>;
940+
// otherwise we may over-decrement the budget number.
941+
if _, exist := pdb.Status.DisruptedPods[pod.Name]; !exist {
942+
pdbsAllowed[i]--
943+
}
939944
// We have found a matching PDB.
940-
if pdbsAllowed[i] <= 0 {
945+
if pdbsAllowed[i] < 0 {
941946
pdbForPodIsViolated = true
942-
} else {
943-
// Only decrement the matched pdb when it's not in its <DisruptedPods>;
944-
// otherwise we may over-decrement the budget number.
945-
if _, exist := pdb.Status.DisruptedPods[pod.Name]; !exist {
946-
pdbsAllowed[i]--
947-
}
948947
}
949948
}
950949
}

0 commit comments

Comments
 (0)