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 device share plugins npe #3351

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion pkg/scheduler/api/devices/nvidia/vgpu/device_info.go
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ func NewGPUDevices(name string, node *v1.Node) *GPUDevices {
klog.Infof("node %v device %s leave", node.Name, handshake)

tmppat := make(map[string]string)
tmppat[handshake] = "Deleted_" + time.Now().Format("2006.01.02 15:04:05")
tmppat[VolcanoVGPUHandshake] = "Deleted_" + time.Now().Format("2006.01.02 15:04:05")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@archlitchi plz check this changes. I am not familiar with this vgpu feaure.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, i didn't noticed that, thanks for fixing:)

patchNodeAnnotations(node, tmppat)
return nil
}
Expand Down
18 changes: 12 additions & 6 deletions pkg/scheduler/plugins/deviceshare/deviceshare.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ package deviceshare

import (
"fmt"
"reflect"

"k8s.io/klog/v2"

Expand Down Expand Up @@ -76,12 +77,17 @@ func (dp *deviceSharePlugin) OnSessionOpen(ssn *framework.Session) {
// Check PredicateWithCache
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,
})
return predicateStatus, fmt.Errorf("node not initialized with device %s", val)
if reflect.ValueOf(dev).IsNil() {
// TODO When a pod requests a device of the current type, but the current node does not have such a device, an error is thrown
if dev == nil || dev.HasDeviceRequest(task.Pod) {
predicateStatus = append(predicateStatus, &api.Status{
Code: devices.Unschedulable,
Reason: "node not initialized with device" + val,
})
return predicateStatus, fmt.Errorf("node not initialized with device %s", val)
}
klog.V(4).Infof("pod %s/%s did not request device %s on %s, skipping it", task.Pod.Namespace, task.Pod.Name, val, node.Name)
continue
}
code, msg, err := dev.FilterNode(task.Pod)
filterNodeStatus := &api.Status{
Expand Down