GoogleCloudPlatform/kubernetes — pull request #1752 by ddysher (2014-10-12 20:46:15+00:00)
Title: Use DesiredState Host in scheduler predicate

This is an attempt to fix #1751

Method MapPodsToMachines always returns a map of empty host to a list of pods, thus when passing existing pods to predicate, predicate will always get an empty list. In this case, all predicates will return true, even if there is an existing port conflit. If we get unlucky, the node that has the highest priority (least used resources) is the node has port conflit, then scheduler will do a retry but still cannot find the correct node.

The problems seems to be that MapPodsToMachines use CurrentState.Host, which is only set in GetPod and ListPods. However, Scheduler uses a PodLister, which is a podCache using Reflector (List and Watch). After initial List, podCache will watch on Pod changs, which won't have the CurrentState.Host correctly set.

This is what I've diagonsed so far, could be wrong; but the problem seems to go away (Run 200+ times without error).