mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-08-16 07:13:53 +00:00
Merge pull request #130059 from googs1025/fix/dra_allocateOne
chore(dra): move pool validity check to the beginning of pool processing
This commit is contained in:
commit
b7c55c2ed2
@ -595,6 +595,12 @@ func (alloc *allocator) allocateOne(r deviceIndices) (bool, error) {
|
|||||||
|
|
||||||
// We need to find suitable devices.
|
// We need to find suitable devices.
|
||||||
for _, pool := range alloc.pools {
|
for _, pool := range alloc.pools {
|
||||||
|
// If the pool is not valid, then fail now. It's okay when pools of one driver
|
||||||
|
// are invalid if we allocate from some other pool, but it's not safe to
|
||||||
|
// allocated from an invalid pool.
|
||||||
|
if pool.IsInvalid {
|
||||||
|
return false, fmt.Errorf("pool %s is invalid: %s", pool.Pool, pool.InvalidReason)
|
||||||
|
}
|
||||||
for _, slice := range pool.Slices {
|
for _, slice := range pool.Slices {
|
||||||
for deviceIndex := range slice.Spec.Devices {
|
for deviceIndex := range slice.Spec.Devices {
|
||||||
deviceID := DeviceID{Driver: pool.Driver, Pool: pool.Pool, Device: slice.Spec.Devices[deviceIndex].Name}
|
deviceID := DeviceID{Driver: pool.Driver, Pool: pool.Pool, Device: slice.Spec.Devices[deviceIndex].Name}
|
||||||
@ -615,13 +621,6 @@ func (alloc *allocator) allocateOne(r deviceIndices) (bool, error) {
|
|||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
// If the pool is not valid, then fail now. It's okay when pools of one driver
|
|
||||||
// are invalid if we allocate from some other pool, but it's not safe to
|
|
||||||
// allocated from an invalid pool.
|
|
||||||
if pool.IsInvalid {
|
|
||||||
return false, fmt.Errorf("pool %s is invalid: %s", pool.Pool, pool.InvalidReason)
|
|
||||||
}
|
|
||||||
|
|
||||||
// Finally treat as allocated and move on to the next device.
|
// Finally treat as allocated and move on to the next device.
|
||||||
device := deviceWithID{
|
device := deviceWithID{
|
||||||
id: deviceID,
|
id: deviceID,
|
||||||
|
Loading…
Reference in New Issue
Block a user