-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbind.go
26 lines (23 loc) · 759 Bytes
/
bind.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
package scheduler
import (
"github.com/AliyunContainerService/gpushare-scheduler-extender/pkg/cache"
"k8s.io/apimachinery/pkg/types"
schedulerapi "k8s.io/kubernetes/pkg/scheduler/api"
)
// Bind is responsible for binding node and pod
type Bind struct {
Name string
Func func(podName string, podNamespace string, podUID types.UID, node string, cache *cache.SchedulerCache) error
cache *cache.SchedulerCache
}
// Handler handles the Bind request
func (b Bind) Handler(args schedulerapi.ExtenderBindingArgs) *schedulerapi.ExtenderBindingResult {
err := b.Func(args.PodName, args.PodNamespace, args.PodUID, args.Node, b.cache)
errMsg := ""
if err != nil {
errMsg = err.Error()
}
return &schedulerapi.ExtenderBindingResult{
Error: errMsg,
}
}