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 the problem that the program crashes if the gpuShare Devices is empty #2751

Merged
merged 1 commit into from
May 23, 2023
Merged
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
30 changes: 23 additions & 7 deletions pkg/scheduler/plugins/predicates/predicates.go
Original file line number Diff line number Diff line change
Expand Up @@ -197,12 +197,18 @@ func (pp *predicatesPlugin) OnSessionOpen(ssn *framework.Session) {
}
//predicate gpu sharing
for _, val := range api.RegisteredDevices {
if nodeInfo.Others[val].(api.Devices).HasDeviceRequest(pod) {
err := nodeInfo.Others[val].(api.Devices).Allocate(ssn.KubeClient(), pod)
if devices, ok := nodeInfo.Others[val].(api.Devices); ok {
if !devices.HasDeviceRequest(pod) {
continue
}

err := devices.Allocate(ssn.KubeClient(), pod)
if err != nil {
klog.Errorf("AllocateToPod failed %s", err.Error())
return
}
} else {
klog.Warningf("Devices %s assertion conversion failed, skip", val)
}
}
node.AddPod(pod)
Expand All @@ -225,13 +231,19 @@ func (pp *predicatesPlugin) OnSessionOpen(ssn *framework.Session) {
}

for _, val := range api.RegisteredDevices {
if nodeInfo.Others[val].(api.Devices).HasDeviceRequest(pod) {
if devices, ok := nodeInfo.Others[val].(api.Devices); ok {
if !devices.HasDeviceRequest(pod) {
continue
}

// deallocate pod gpu id
err := nodeInfo.Others[val].(api.Devices).Release(ssn.KubeClient(), pod)
err := devices.Release(ssn.KubeClient(), pod)
if err != nil {
klog.Errorf(err.Error())
return
}
} else {
klog.Warningf("Devices %s assertion conversion failed, skip", val)
}
}

Expand Down Expand Up @@ -406,9 +418,13 @@ func (pp *predicatesPlugin) OnSessionOpen(ssn *framework.Session) {
}

for _, val := range api.RegisteredDevices {
fit, err = node.Others[val].(api.Devices).FilterNode(task.Pod)
if err != nil {
return err
if devices, ok := node.Others[val].(api.Devices); ok {
fit, err = devices.FilterNode(task.Pod)
if err != nil {
return err
}
} else {
klog.Warningf("Devices %s assertion conversion failed, skip", val)
}
}

Expand Down