Skip to content

Commit a41f7cb

Browse files
committed
fix empty AllocateFrom handling
1 parent 7ec0511 commit a41f7cb

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

crishim/pkg/device/devicemanager.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ func (d *DevicesManager) AllocateDevices(pod *types.PodInfo, cont *types.Contain
108108
for i, device := range d.Devices {
109109
if d.Operational[i] {
110110
alloc, err := device.Allocate(pod, cont)
111-
if err == nil {
111+
if err == nil && alloc != nil {
112112
// only set envs for now
113113
for k, v := range alloc.Envs {
114114
resp.Envs[k] = v

crishim/pkg/kubecri/docker_container.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,9 +35,13 @@ type dockerExtService struct {
3535
}
3636

3737
func (d *dockerExtService) modifyContainerConfig(pod *types.PodInfo, cont *types.ContainerInfo, config *runtimeapi.ContainerConfig) error {
38+
numAllocateFrom := len(cont.AllocateFrom) // may be zero from old scheduler
39+
if numAllocateFrom == 0 {
40+
return nil
41+
}
42+
3843
glog.V(3).Infof("original container config: %s", config.String())
3944

40-
numAllocateFrom := len(cont.AllocateFrom) // may be zero from old scheduler
4145
var visDev *string
4246
// https://github.com/NVIDIA/nvidia-container-runtime#nvidia_visible_devices
4347
for _, v := range config.Envs {

0 commit comments

Comments
 (0)