Merge pull request #33086 from ivan4th/fix-possible-panic-in-pod-affinity-checker

Automatic merge from submit-queue

Fix possible panic in PodAffinityChecker

In `PodAffinityChecker.getMatchingAntiAffinityTerms()` `affinity.PodAntiAffinity` can be `nil` in this place. This problem occurs e.g. when `nil` is passed as `meta` to `PodAffinityChecker.InterPodAffinityMatches()`.

Stumbled upon it while working on #31136 (someone PTAL at that PR too, I've submitted it a month ago and seemingly no one noticed it), kube-controller-manager was crashing there.
This commit is contained in:
Kubernetes Submit Queue 2016-09-21 00:24:44 -07:00 committed by GitHub
commit d17c6b903a

View File

@ -968,7 +968,7 @@ func (c *PodAffinityChecker) getMatchingAntiAffinityTerms(pod *api.Pod, allPods
if err != nil {
return nil, err
}
if affinity.PodAntiAffinity != nil {
if affinity != nil && affinity.PodAntiAffinity != nil {
existingPodNode, err := c.info.GetNodeInfo(existingPod.Spec.NodeName)
if err != nil {
return nil, err