Change:
} return count } <del> // CalculateAntiAffinityPriorityMap spreads pods by minimizing the number of pods belonging to the same service // on given machine func (s *ServiceAntiAffinity) CalculateAntiAffinityPriorityMap(pod *v1.Pod, meta interface{}, nodeInfo *schedulernodeinfo.NodeInfo) (framework.NodeScore, error) { var firstServiceSelector labels.Selector node := nodeInfo.Node() if node == nil { return framework.NodeScore{}, fmt.Errorf("node not found") } priorityMeta, ok := meta.(*priorityMetadata) if ok { firstServiceSelector = priorityMeta.podFirstServiceSelector } else { firstServiceSelector = getFirstServiceSelector(pod, s.serviceLister) } // Pods matched namespace,selector on current node. var selector labels.Selector if firstServiceSelector != nil { selector = firstServiceSelector } else { selector = labels.NewSelector() } score := countMatchingPods(pod.Namespace, selector, nodeInfo) return framework.NodeScore{ Name:  node.Name, Score: int64(score), }, nil } // CalculateAntiAffinityPriorityReduce computes each node score with the same value for a particular label. // The label to be considered is provided to the struct (ServiceAntiAffinity). func (s *ServiceAntiAffinity) CalculateAntiAffinityPriorityReduce(pod *v1.Pod, meta interface{}, sharedLister schedulerlisters.SharedLister, result framework.NodeScoreList) error { reduceResult := make([]float64, len(result)) for _, label := range s.labels { if err := s.updateNodeScoresForLabel(sharedLister, result, reduceResult, label); err != nil { return err } } // Update the result after all labels have been evaluated. for i, nodeScore := range reduceResult { result[i].Score = int64(nodeScore) } return nil } // updateNodeScoresForLabel updates the node scores for a single label. Note it does not update the // original result from the map phase directly, but instead updates the reduceResult, which is used // to update the original result finally. This makes sure that each call to updateNodeScoresForLabel // receives the same mapResult to work with. // Why are doing this? This is a workaround for the migration from priorities to score plugins. // Historically the priority is designed to handle only one label, and multiple priorities are configured // to work with multiple labels. Using multiple plugins is not allowed in the new framework. Therefore // we need to modify the old priority to be able to handle multiple labels so that it can be mapped // to a single plugin. This will be deprecated soon. func (s *ServiceAntiAffinity) updateNodeScoresForLabel(sharedLister schedulerlisters.SharedLister, mapResult framework.NodeScoreList, reduceResult []float64, label string) error { var numServicePods int64 var labelValue string podCounts := map[string]int64{} labelNodesStatus := map[string]string{} maxPriorityFloat64 := float64(framework.MaxNodeScore) for _, hostPriority := range mapResult { numServicePods += hostPriority.Score nodeInfo, err := sharedLister.NodeInfos().Get(hostPriority.Name) if err != nil { return err } if !labels.Set(nodeInfo.Node().Labels).Has(label) { continue } labelValue = labels.Set(nodeInfo.Node().Labels).Get(label) labelNodesStatus[hostPriority.Name] = labelValue podCounts[labelValue] += hostPriority.Score } //score int - scale of 0-maxPriority // 0 being the lowest priority and maxPriority being the highest for i, hostPriority := range mapResult { labelValue, ok := labelNodesStatus[hostPriority.Name] if !ok { continue } // initializing to the default/max node score of maxPriority fScore := maxPriorityFloat64 if numServicePods > 0 { fScore = maxPriorityFloat64 * (float64(numServicePods-podCounts[labelValue]) / float64(numServicePods)) } // The score of current label only accounts for 1/len(s.labels) of the total score. // The policy API definition only allows a single label to be configured, associated with a weight. // This is compensated by the fact that the total weight is the sum of all weights configured // in each policy config. reduceResult[i] += fScore / float64(len(s.labels)) } return nil } </del>

Discussion:
/sig scheduling /priority important-soon See as an example. /assign
/unassign /help
/assign
/remove-help