Skip to content

Commit b7c55c2

Browse files
authored
Merge pull request kubernetes#130059 from googs1025/fix/dra_allocateOne
chore(dra): move pool validity check to the beginning of pool processing
2 parents 69ab91a + b30944b commit b7c55c2

File tree

1 file changed

+6
-7
lines changed
  • staging/src/k8s.io/dynamic-resource-allocation/structured

1 file changed

+6
-7
lines changed

staging/src/k8s.io/dynamic-resource-allocation/structured/allocator.go

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -595,6 +595,12 @@ func (alloc *allocator) allocateOne(r deviceIndices) (bool, error) {
595595

596596
// We need to find suitable devices.
597597
for _, pool := range alloc.pools {
598+
// If the pool is not valid, then fail now. It's okay when pools of one driver
599+
// are invalid if we allocate from some other pool, but it's not safe to
600+
// allocated from an invalid pool.
601+
if pool.IsInvalid {
602+
return false, fmt.Errorf("pool %s is invalid: %s", pool.Pool, pool.InvalidReason)
603+
}
598604
for _, slice := range pool.Slices {
599605
for deviceIndex := range slice.Spec.Devices {
600606
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) {
615621
continue
616622
}
617623

618-
// If the pool is not valid, then fail now. It's okay when pools of one driver
619-
// are invalid if we allocate from some other pool, but it's not safe to
620-
// allocated from an invalid pool.
621-
if pool.IsInvalid {
622-
return false, fmt.Errorf("pool %s is invalid: %s", pool.Pool, pool.InvalidReason)
623-
}
624-
625624
// Finally treat as allocated and move on to the next device.
626625
device := deviceWithID{
627626
id: deviceID,

0 commit comments

Comments
 (0)