diff --git a/staging/src/k8s.io/dynamic-resource-allocation/structured/allocator.go b/staging/src/k8s.io/dynamic-resource-allocation/structured/allocator.go index 74b82c6f1a7..6e05234074a 100644 --- a/staging/src/k8s.io/dynamic-resource-allocation/structured/allocator.go +++ b/staging/src/k8s.io/dynamic-resource-allocation/structured/allocator.go @@ -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,