Achilleas Tzenetopoulos 5 年 前
コミット
fa43f757f6
共有1 個のファイルを変更した52 個の追加0 個の削除を含む
  1. 52 0
      kubernetes-v1.15.4/pkg/scheduler/core/extender.go

+ 52 - 0
kubernetes-v1.15.4/pkg/scheduler/core/extender.go

@@ -356,6 +356,58 @@ func (h *HTTPExtender) Prioritize(pod *v1.Pod, nodes []*v1.Node) (*schedulerapi.
 	return &result, h.weight, nil
 }
 
+//------------------------------------------------------------------------------------------------
+//------------------------------------------------------------------------------------------------
+// ---------START OF CUSTOMIZATION------------------------------------------------------------------
+//------------------------------------------------------------------------------------------------
+//------------------------------------------------------------------------------------------------
+func (h *HTTPExtender) CustomPrioritize(pod *v1.Pod, nodes []*v1.Node) (*schedulerapi.CustomHostPriorityList, int, error) {
+	var (
+		result    schedulerapi.CustomHostPriorityList
+		nodeList  *v1.NodeList
+		nodeNames *[]string
+		args      *schedulerapi.ExtenderArgs
+	)
+
+	if h.prioritizeVerb == "" {
+		result := schedulerapi.CustomHostPriorityList{}
+		for _, node := range nodes {
+			result = append(result, schedulerapi.CustomHostPriority{Host: node.Name, Score: 0})
+		}
+		return &result, 0, nil
+	}
+
+	if h.nodeCacheCapable {
+		nodeNameSlice := make([]string, 0, len(nodes))
+		for _, node := range nodes {
+			nodeNameSlice = append(nodeNameSlice, node.Name)
+		}
+		nodeNames = &nodeNameSlice
+	} else {
+		nodeList = &v1.NodeList{}
+		for _, node := range nodes {
+			nodeList.Items = append(nodeList.Items, *node)
+		}
+	}
+
+	args = &schedulerapi.ExtenderArgs{
+		Pod:       pod,
+		Nodes:     nodeList,
+		NodeNames: nodeNames,
+	}
+
+	if err := h.send(h.prioritizeVerb, args, &result); err != nil {
+		return nil, 0, err
+	}
+	return &result, h.weight, nil
+}
+
+//------------------------------------------------------------------------------------------------
+//------------------------------------------------------------------------------------------------
+// ---------END OF CUSTOMIZATION------------------------------------------------------------------
+//------------------------------------------------------------------------------------------------
+//------------------------------------------------------------------------------------------------
+
 // Bind delegates the action of binding a pod to a node to the extender.
 func (h *HTTPExtender) Bind(binding *v1.Binding) error {
 	var result schedulerapi.ExtenderBindingResult