Skip to content

Commit

Permalink
fix: FilterNode err miss predicateStatus
Browse files Browse the repository at this point in the history
Signed-off-by: googs1025 <googs1025@gmail.com>
  • Loading branch information
googs1025 committed May 6, 2024
1 parent 97f2d3a commit d42e1be
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 14 deletions.
12 changes: 6 additions & 6 deletions pkg/scheduler/api/shared_device_pool.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,13 +32,13 @@ type Devices interface {
//following two functions used in node_info
//AddResource is to add the corresponding device resource of this 'pod' into current scheduler cache
AddResource(pod *v1.Pod)
//SubResoure is to substract the corresponding device resource of this 'pod' from current scheduler cache
//SubResource is to subtract the corresponding device resource of this 'pod' from current scheduler cache
SubResource(pod *v1.Pod)

//following four functions used in predicate
//HasDeviceRequest checks if the 'pod' request this device
HasDeviceRequest(pod *v1.Pod) bool
//FiltreNode checks if the 'pod' fit in current node
// FilterNode checks if the 'pod' fit in current node
// The first return value represents the filtering result, and the value range is "0, 1, 2, 3"
// 0: Success
// Success means that plugin ran correctly and found pod schedulable.
Expand All @@ -58,15 +58,15 @@ type Devices interface {
// that the pod can get scheduled with preemption.
// The accompanying status message should explain why the pod is unschedulable.
FilterNode(pod *v1.Pod) (int, string, error)
//Allocate action in predicate
// Allocate action in predicate
Allocate(kubeClient kubernetes.Interface, pod *v1.Pod) error
//Release action in predicate
// Release action in predicate
Release(kubeClient kubernetes.Interface, pod *v1.Pod) error

//IgnredDevices notify vc-scheduler to ignore devices in return list
// GetIgnoredDevices IgnoredDevices notify vc-scheduler to ignore devices in return list
GetIgnoredDevices() []string

//used for debug and monitor
// GetStatus used for debug and monitor
GetStatus() string
}

Expand Down
20 changes: 12 additions & 8 deletions pkg/scheduler/plugins/deviceshare/deviceshare.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,14 @@ func enablePredicate(args framework.Arguments) {
}
}

func createStatus(code int, reason string) *api.Status {
status := api.Status{
Code: code,
Reason: reason,
}
return &status
}

func (dp *deviceSharePlugin) OnSessionOpen(ssn *framework.Session) {
enablePredicate(dp.pluginArguments)
// Register event handlers to update task info in PodLister & nodeMap
Expand All @@ -77,20 +85,16 @@ func (dp *deviceSharePlugin) OnSessionOpen(ssn *framework.Session) {
for _, val := range api.RegisteredDevices {
if dev, ok := node.Others[val].(api.Devices); ok {
if dev == nil {
predicateStatus = append(predicateStatus, &api.Status{
Code: devices.Unschedulable,
Reason: "node not initialized with device" + val,
})
predicateStatus = append(predicateStatus,
createStatus(devices.Unschedulable, "node not initialized with device"+val))
return predicateStatus, fmt.Errorf("node not initialized with device %s", val)
}
code, msg, err := dev.FilterNode(task.Pod)
filterNodeStatus := &api.Status{
Code: code,
Reason: msg,
}
if err != nil {
predicateStatus = append(predicateStatus, createStatus(code, msg))
return predicateStatus, err
}
filterNodeStatus := createStatus(code, msg)
if filterNodeStatus.Code != api.Success {
predicateStatus = append(predicateStatus, filterNodeStatus)
return predicateStatus, fmt.Errorf("plugin device filternode predicates failed %s", msg)
Expand Down

0 comments on commit d42e1be

Please sign in to comment.