Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: FilterNode err miss predicateStatus #3450

Merged
merged 1 commit into from
May 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 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
Loading