mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-31 07:20:13 +00:00
Harden callGetPreferredAllocationIfAvailable() return value
Previously, we didn't check the contents of the result after calling out to the plugin endpoint. This could have resulted in errors if the plugin returned either 'nil' or an empty result. This patch fixes this.
This commit is contained in:
parent
d87365494a
commit
67ecc11c44
@ -997,8 +997,10 @@ func (m *ManagerImpl) callGetPreferredAllocationIfAvailable(podUID, contName, re
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("device plugin GetPreferredAllocation rpc failed with err: %v", err)
|
||||
}
|
||||
// TODO: Add metrics support for init RPC
|
||||
return sets.NewString(resp.ContainerResponses[0].DeviceIDs...), nil
|
||||
if resp != nil && len(resp.ContainerResponses) > 0 {
|
||||
return sets.NewString(resp.ContainerResponses[0].DeviceIDs...), nil
|
||||
}
|
||||
return sets.NewString(), nil
|
||||
}
|
||||
|
||||
// sanitizeNodeAllocatable scans through allocatedDevices in the device manager
|
||||
|
Loading…
Reference in New Issue
Block a user