Skip to content

Commit

Permalink
Added comments and minor changes based on PR feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
Abhishek Gupta committed Jan 13, 2015
1 parent 40df5f6 commit c20d062
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions pkg/scheduler/spreading.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ func NewServiceSpreadPriority(serviceLister ServiceLister) PriorityFunction {
// CalculateSpreadPriority spreads pods by minimizing the number of pods on the same machine with the same labels.
// Importantly, if there are services in the system that span multiple heterogenous sets of pods, this spreading priority
// may not provide optimal spreading for the members of that Service.
// TODO: consider if we want to include Service label sets in the scheduling priority.
func (s *ServiceSpread) CalculateSpreadPriority(pod api.Pod, podLister PodLister, minionLister MinionLister) (HostPriorityList, error) {
var maxCount int
var pods []api.Pod
Expand Down Expand Up @@ -95,6 +94,9 @@ func NewServiceAntiAffinityPriority(serviceLister ServiceLister, label string) P
return antiAffinity.CalculateAntiAffinityPriority
}

// CalculateAntiAffinityPriority spreads pods by minimizing the number of pods belonging to the same service
// on machines with the same value for a particular label.
// The label to be considered is provided to the struct (ServiceAntiAffinity).
func (s *ServiceAntiAffinity) CalculateAntiAffinityPriority(pod api.Pod, podLister PodLister, minionLister MinionLister) (HostPriorityList, error) {
var pods []api.Pod

Expand Down Expand Up @@ -128,11 +130,11 @@ func (s *ServiceAntiAffinity) CalculateAntiAffinityPriority(pod api.Pod, podList

podCounts := map[string]int{}
for _, pod := range pods {
zone, exists := labeledMinions[pod.Status.Host]
label, exists := labeledMinions[pod.Status.Host]
if !exists {
continue
}
podCounts[zone]++
podCounts[label]++
}

numServicePods := len(pods)
Expand Down

0 comments on commit c20d062

Please sign in to comment.