chore(dra): move pool validity check to the beginning of pool processing

This commit is contained in:
googs1025
2025-02-10 14:04:50 +08:00
parent 69ab91a5c5
commit b30944b071

View File

@@ -595,6 +595,12 @@ func (alloc *allocator) allocateOne(r deviceIndices) (bool, error) {
// We need to find suitable devices.
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 deviceIndex := range slice.Spec.Devices {
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
}
// 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.
device := deviceWithID{
id: deviceID,