-
Notifications
You must be signed in to change notification settings - Fork 0
/
gpushare-predicate.go
40 lines (35 loc) · 1.07 KB
/
gpushare-predicate.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
package scheduler
import (
"fmt"
"log"
"github.com/CERIT-SC/nvidia-scheduler-extender/pkg/cache"
"github.com/CERIT-SC/nvidia-scheduler-extender/pkg/utils"
"k8s.io/api/core/v1"
"k8s.io/client-go/kubernetes"
)
func NewGPUsharePredicate(clientset *kubernetes.Clientset, c *cache.SchedulerCache) *Predicate {
return &Predicate{
Name: "gpusharingfilter",
Func: func(pod *v1.Pod, nodeName string, c *cache.SchedulerCache) (bool, error) {
log.Printf("info: check if the pod name %s can be scheduled on node %s", pod.Name, nodeName)
nodeInfo, err := c.GetNodeInfo(nodeName)
if err != nil {
return false, err
}
if !utils.IsGPUSharingNode(nodeInfo.GetNode()) {
return false, fmt.Errorf("The node %s is not for GPU share, need skip", nodeName)
}
allocatable := nodeInfo.Assume(pod)
if !allocatable {
return false, fmt.Errorf("Insufficient GPU Memory in one device")
} else {
log.Printf("info: The pod %s in the namespace %s can be scheduled on %s",
pod.Name,
pod.Namespace,
nodeName)
}
return true, nil
},
cache: c,
}
}