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:
Kubernetes Prow Robot 2025-02-09 23:23:57 -08:00 committed by GitHub
commit b7c55c2ed2
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

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,