mirror of
https://github.com/kubernetes/kubernetes.git
synced 2026-06-03 13:47:44 -04:00
Merge pull request #138885 from takonomura/fix-dra-all-consumed-counters
DRA: fix AllocationModeAll with consumed counters
This commit is contained in:
commit
cc82d8b02a
4 changed files with 40 additions and 0 deletions
|
|
@ -1233,6 +1233,43 @@ func TestAllocator(t *testing.T,
|
|||
deviceAllocationResult(req0, driverA, pool1, device1, false),
|
||||
)},
|
||||
},
|
||||
"all-devices-with-consumed-counters": {
|
||||
features: Features{
|
||||
PartitionableDevices: true,
|
||||
},
|
||||
claimsToAllocate: objects(claimWithRequests(claim0, nil, resourceapi.DeviceRequest{
|
||||
Name: req0,
|
||||
Exactly: &resourceapi.ExactDeviceRequest{
|
||||
AllocationMode: resourceapi.DeviceAllocationModeAll,
|
||||
DeviceClassName: classA,
|
||||
},
|
||||
})),
|
||||
classes: objects(class(classA, driverA)),
|
||||
slices: unwrapResourceSlices(
|
||||
sliceWithDevices(slice1, node1, resourcePool(pool1, 2), driverA,
|
||||
device(device1, nil, nil).withDeviceCounterConsumption(
|
||||
deviceCounterConsumption(counterSet1,
|
||||
map[string]resource.Quantity{
|
||||
"memory": resource.MustParse("4Gi"),
|
||||
},
|
||||
),
|
||||
),
|
||||
),
|
||||
sliceWithCounterSets(slice2, node1, resourcePool(pool1, 2), driverA,
|
||||
counterSet(counterSet1,
|
||||
map[string]resource.Quantity{
|
||||
"memory": resource.MustParse("8Gi"),
|
||||
},
|
||||
),
|
||||
),
|
||||
),
|
||||
node: node(node1, region1),
|
||||
|
||||
expectResults: []any{allocationResult(
|
||||
localNodeSelector(node1),
|
||||
deviceAllocationResult(req0, driverA, pool1, device1, false),
|
||||
)},
|
||||
},
|
||||
"all-devices-many": {
|
||||
claimsToAllocate: objects(claimWithRequests(claim0, nil, resourceapi.DeviceRequest{
|
||||
Name: req0,
|
||||
|
|
|
|||
|
|
@ -568,6 +568,7 @@ func (alloc *allocator) validateDeviceRequest(request requestAccessor, parentReq
|
|||
id: DeviceID{Driver: slice.Spec.Driver, Pool: slice.Spec.Pool.Name, Device: slice.Spec.Devices[deviceIndex].Name},
|
||||
Device: &slice.Spec.Devices[deviceIndex],
|
||||
slice: slice,
|
||||
pool: pool,
|
||||
}
|
||||
if alloc.features.ConsumableCapacity {
|
||||
// Next validate whether resource request over capacity
|
||||
|
|
|
|||
|
|
@ -565,6 +565,7 @@ func (alloc *allocator) validateDeviceRequest(request requestAccessor, parentReq
|
|||
id: DeviceID{Driver: slice.Spec.Driver, Pool: slice.Spec.Pool.Name, Device: slice.Spec.Devices[deviceIndex].Name},
|
||||
Device: &slice.Spec.Devices[deviceIndex],
|
||||
slice: slice,
|
||||
pool: pool,
|
||||
}
|
||||
if alloc.features.ConsumableCapacity {
|
||||
// Next validate whether resource request over capacity
|
||||
|
|
|
|||
|
|
@ -471,6 +471,7 @@ func (alloc *allocator) validateDeviceRequest(request requestAccessor, parentReq
|
|||
id: DeviceID{Driver: slice.Spec.Driver, Pool: slice.Spec.Pool.Name, Device: slice.Spec.Devices[deviceIndex].Name},
|
||||
Device: &slice.Spec.Devices[deviceIndex],
|
||||
slice: slice,
|
||||
pool: pool,
|
||||
}
|
||||
requestData.allDevices = append(requestData.allDevices, device)
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue