Fix a preemption bug when pods are matched by pdb.Status.DisruptedPods

This commit is contained in:
Wei Huang 2020-06-24 09:37:15 -07:00
parent dc0122ca6a
commit 488621815f
No known key found for this signature in database
GPG Key ID: BE5E9752F8B6E005

View File

@ -936,15 +936,14 @@ func filterPodsWithPDBViolation(pods []*v1.Pod, pdbs []*policy.PodDisruptionBudg
if selector.Empty() || !selector.Matches(labels.Set(pod.Labels)) {
continue
}
// Only decrement the matched pdb when it's not in its <DisruptedPods>;
// otherwise we may over-decrement the budget number.
if _, exist := pdb.Status.DisruptedPods[pod.Name]; !exist {
pdbsAllowed[i]--
}
// We have found a matching PDB.
if pdbsAllowed[i] <= 0 {
if pdbsAllowed[i] < 0 {
pdbForPodIsViolated = true
} else {
// Only decrement the matched pdb when it's not in its <DisruptedPods>;
// otherwise we may over-decrement the budget number.
if _, exist := pdb.Status.DisruptedPods[pod.Name]; !exist {
pdbsAllowed[i]--
}
}
}
}