@@ -560,6 +560,9 @@ type deviceAllocationMetadata struct {
560560 deviceWithID DeviceWithID
561561 consumedCapacity map [resourcev1.QualifiedName ]resource.Quantity
562562 requestName RequestName
563+ // adminAccess marks an allocation that binds for privileged monitoring without
564+ // consuming the device (KEP-5018). Excluded from the committed device set.
565+ adminAccess bool
563566}
564567
565568// allocate runs a per-instance-type DFS over in-cluster and template devices.
@@ -633,10 +636,14 @@ func (a *allocator) allocate(instanceTypes []InstanceTypeID) (*AllocationResult,
633636 a .allocatingCapacity = nil
634637 a .templateAllocatingCapacity = nil
635638
636- deviceIDsByIT [itID ] = make ([]DeviceID , len (a .allocatedDevicesMetadata ))
639+ deviceIDsByIT [itID ] = make ([]DeviceID , 0 , len (a .allocatedDevicesMetadata ))
637640 itReqs := scheduling .NewRequirements ()
638- for di , da := range a .allocatedDevicesMetadata {
639- deviceIDsByIT [itID ][di ] = da .deviceWithID .ID
641+ for _ , da := range a .allocatedDevicesMetadata {
642+ // Admin-access devices are part of the solution but don't consume the device,
643+ // so they're excluded from the set the tracker commits as allocated (KEP-5018).
644+ if ! da .adminAccess {
645+ deviceIDsByIT [itID ] = append (deviceIDsByIT [itID ], da .deviceWithID .ID )
646+ }
640647 meta := claimAllocMeta [da .claimIndex ]
641648 // Update the contributed requirements for the device, each devices contributed requirements are intersected to
642649 // find the contributed requirements for the instance type.
@@ -853,15 +860,22 @@ func (a *allocator) tryDevice(
853860 deviceID := dw .ID
854861
855862 // 1. Availability check — multi-alloc devices use capacity as the gatekeeper;
856- // exclusive devices use binary allocation tracking.
863+ // exclusive devices use binary allocation tracking. Admin-access requests bypass
864+ // both: they may bind to already-allocated devices and don't consume capacity
865+ // (KEP-5018). The in-DFS dedupe still applies so a request gets distinct devices.
857866 var consumed map [resourcev1.QualifiedName ]resource.Quantity
858- if dw .AllowMultipleAllocations {
867+ switch {
868+ case rd .AdminAccess :
869+ if a .allocatedDevices .Has (deviceID ) {
870+ return false
871+ }
872+ case dw .AllowMultipleAllocations :
859873 var ok bool
860874 consumed , ok = a .checkCapacity (dw .Device , deviceID , rd )
861875 if ! ok {
862876 return false
863877 }
864- } else {
878+ default :
865879 if a .allocationTracker .IsAllocated (deviceID , a .nodeClaim , a .itID ) {
866880 return false
867881 }
@@ -870,8 +884,9 @@ func (a *allocator) tryDevice(
870884 }
871885 }
872886
873- // 2. Counter verification — check shared counter budgets.
874- if len (dw .ConsumesCounters ) > 0 {
887+ // 2. Counter verification — check shared counter budgets. Admin-access requests
888+ // ignore resource allocations, so counters are neither checked nor consumed.
889+ if ! rd .AdminAccess && len (dw .ConsumesCounters ) > 0 {
875890 poolKey := PoolKey {Driver : deviceID .Driver , Pool : deviceID .Pool }
876891 var remainingCounterSets map [string ]map [string ]resourcev1.Counter
877892 if deviceID .Template {
@@ -943,17 +958,22 @@ func (a *allocator) tryDevice(
943958 deviceWithID : dw ,
944959 consumedCapacity : consumed ,
945960 requestName : rd .Name ,
961+ adminAccess : rd .AdminAccess ,
946962 })
947- if dw .AllowMultipleAllocations {
948- // Ensures a multi-allocatable device has a allocating capacity map, even if it has no capacity dimensions.
949- // This is needed so that Commit() can identify multi-alloc devices via capacityConsumptionByIT presence.
950- allocatingCapacityMap := lo .Ternary (deviceID .Template , a .templateAllocatingCapacity , a .allocatingCapacity )
951- if allocatingCapacityMap [deviceID ] == nil {
952- allocatingCapacityMap [deviceID ] = make (map [resourcev1.QualifiedName ]resource.Quantity )
963+ // Admin-access allocations don't consume the device, so skip all capacity/counter
964+ // bookkeeping (KEP-5018).
965+ if ! rd .AdminAccess {
966+ if dw .AllowMultipleAllocations {
967+ // Ensures a multi-allocatable device has a allocating capacity map, even if it has no capacity dimensions.
968+ // This is needed so that Commit() can identify multi-alloc devices via capacityConsumptionByIT presence.
969+ allocatingCapacityMap := lo .Ternary (deviceID .Template , a .templateAllocatingCapacity , a .allocatingCapacity )
970+ if allocatingCapacityMap [deviceID ] == nil {
971+ allocatingCapacityMap [deviceID ] = make (map [resourcev1.QualifiedName ]resource.Quantity )
972+ }
953973 }
974+ a .deductAllocatingCapacity (consumed , deviceID , deviceID .Template )
975+ a .deductAllocatingCounters (dw .Device , PoolKey {Driver : deviceID .Driver , Pool : deviceID .Pool }, deviceID .Template )
954976 }
955- a .deductAllocatingCapacity (consumed , deviceID , deviceID .Template )
956- a .deductAllocatingCounters (dw .Device , PoolKey {Driver : deviceID .Driver , Pool : deviceID .Pool }, deviceID .Template )
957977
958978 // Recurse.
959979 if a .dfs (claimIdx , reqIdx , subReqIdx , slotIdx + 1 ) {
@@ -962,8 +982,10 @@ func (a *allocator) tryDevice(
962982
963983 // Backtrack — undo in reverse order of application: capacity, counters, allocation, then
964984 // requirements/pools, then constraints.
965- a .restoreAllocatingCapacity (consumed , deviceID , deviceID .Template )
966- a .restoreAllocatingCounters (dw .Device , PoolKey {Driver : deviceID .Driver , Pool : deviceID .Pool }, deviceID .Template )
985+ if ! rd .AdminAccess {
986+ a .restoreAllocatingCapacity (consumed , deviceID , deviceID .Template )
987+ a .restoreAllocatingCounters (dw .Device , PoolKey {Driver : deviceID .Driver , Pool : deviceID .Pool }, deviceID .Template )
988+ }
967989 a .allocatedDevicesMetadata = a .allocatedDevicesMetadata [:len (a .allocatedDevicesMetadata )- 1 ]
968990 a .allocatedDevices .Delete (deviceID )
969991
0 commit comments