mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-09-12 20:57:20 +00:00
Scheduler changes for extensibility
This commit is contained in:
@@ -38,10 +38,15 @@ func (g *genericScheduler) Schedule(pod api.Pod, minionLister MinionLister) (str
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
if len(minions.Items) == 0 {
|
||||
return "", fmt.Errorf("no minions available to schedule pods")
|
||||
}
|
||||
|
||||
filteredNodes, err := findNodesThatFit(pod, g.pods, g.predicates, minions)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
|
||||
priorityList, err := g.prioritizer(pod, g.pods, FakeMinionLister(filteredNodes))
|
||||
if err != nil {
|
||||
return "", err
|
||||
@@ -49,6 +54,7 @@ func (g *genericScheduler) Schedule(pod api.Pod, minionLister MinionLister) (str
|
||||
if len(priorityList) == 0 {
|
||||
return "", fmt.Errorf("failed to find a fit for pod: %v", pod)
|
||||
}
|
||||
|
||||
return g.selectHost(priorityList)
|
||||
}
|
||||
|
||||
|
@@ -74,6 +74,7 @@ func isVolumeConflict(volume api.Volume, pod *api.Pod) bool {
|
||||
// TODO: migrate this into some per-volume specific code?
|
||||
func NoDiskConflict(pod api.Pod, existingPods []api.Pod, node string) (bool, error) {
|
||||
manifest := &(pod.Spec)
|
||||
glog.Errorf("custom predicate NoDiskConflict --> node: %s", node)
|
||||
for ix := range manifest.Volumes {
|
||||
for podIx := range existingPods {
|
||||
if isVolumeConflict(manifest.Volumes[ix], &existingPods[podIx]) {
|
||||
@@ -104,6 +105,7 @@ func getResourceRequest(pod *api.Pod) resourceRequest {
|
||||
|
||||
// PodFitsResources calculates fit based on requested, rather than used resources
|
||||
func (r *ResourceFit) PodFitsResources(pod api.Pod, existingPods []api.Pod, node string) (bool, error) {
|
||||
glog.Errorf("custom predicate PodFitsResources --> node: %s", node)
|
||||
podRequest := getResourceRequest(&pod)
|
||||
if podRequest.milliCPU == 0 && podRequest.memory == 0 {
|
||||
// no resources requested always fits.
|
||||
@@ -152,6 +154,7 @@ type NodeSelector struct {
|
||||
|
||||
func (n *NodeSelector) PodSelectorMatches(pod api.Pod, existingPods []api.Pod, node string) (bool, error) {
|
||||
if len(pod.Spec.NodeSelector) == 0 {
|
||||
glog.Errorf("custom predicate PodSelectorMatches --> node: %s", node)
|
||||
return true, nil
|
||||
}
|
||||
selector := labels.SelectorFromSet(pod.Spec.NodeSelector)
|
||||
@@ -163,6 +166,7 @@ func (n *NodeSelector) PodSelectorMatches(pod api.Pod, existingPods []api.Pod, n
|
||||
}
|
||||
|
||||
func PodFitsPorts(pod api.Pod, existingPods []api.Pod, node string) (bool, error) {
|
||||
glog.Errorf("custom predicate PodFitsPorts --> node: %s", node)
|
||||
existingPorts := getUsedPorts(existingPods...)
|
||||
wantPorts := getUsedPorts(pod)
|
||||
for wport := range wantPorts {
|
||||
|
Reference in New Issue
Block a user