synchronization
This commit is contained in:
26
gpushare-scheduler-extender/pkg/scheduler/bind.go
Normal file
26
gpushare-scheduler-extender/pkg/scheduler/bind.go
Normal file
@@ -0,0 +1,26 @@
|
||||
package scheduler
|
||||
|
||||
import (
|
||||
"github.com/AliyunContainerService/gpushare-scheduler-extender/pkg/cache"
|
||||
"k8s.io/apimachinery/pkg/types"
|
||||
schedulerapi "k8s.io/kube-scheduler/extender/v1"
|
||||
)
|
||||
|
||||
// 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,
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user