Skip to content

Commit 6d7f116

Browse files
committed
Complete feature impl, fix issues, add perDeviceNodeSelection support, add tests, address comments, etc.
1 parent ecba6cd commit 6d7f116

File tree

8 files changed

+445
-204
lines changed

8 files changed

+445
-204
lines changed

pkg/scheduler/framework/plugins/dynamicresources/dynamicresources.go

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -102,10 +102,11 @@ type informationForClaim struct {
102102

103103
// DynamicResources is a plugin that ensures that ResourceClaims are allocated.
104104
type DynamicResources struct {
105-
enabled bool
106-
enableAdminAccess bool
107-
enablePrioritizedList bool
108-
enableSchedulingQueueHint bool
105+
enabled bool
106+
enableAdminAccess bool
107+
enablePrioritizedList bool
108+
enableSchedulingQueueHint bool
109+
enablePartitionableDevices bool
109110
enableDeviceTaints bool
110111

111112
fh framework.Handle
@@ -122,11 +123,12 @@ func New(ctx context.Context, plArgs runtime.Object, fh framework.Handle, fts fe
122123
}
123124

124125
pl := &DynamicResources{
125-
enabled: true,
126-
enableAdminAccess: fts.EnableDRAAdminAccess,
127-
enableDeviceTaints: fts.EnableDRADeviceTaints,
128-
enablePrioritizedList: fts.EnableDRAPrioritizedList,
129-
enableSchedulingQueueHint: fts.EnableSchedulingQueueHint,
126+
enabled: true,
127+
enableAdminAccess: fts.EnableDRAAdminAccess,
128+
enableDeviceTaints: fts.EnableDRADeviceTaints,
129+
enablePrioritizedList: fts.EnableDRAPrioritizedList,
130+
enableSchedulingQueueHint: fts.EnableSchedulingQueueHint,
131+
enablePartitionableDevices: fts.EnablePartitionableDevices,
130132

131133
fh: fh,
132134
clientset: fh.ClientSet(),
@@ -455,8 +457,9 @@ func (pl *DynamicResources) PreFilter(ctx context.Context, state *framework.Cycl
455457
return nil, statusError(logger, err)
456458
}
457459
features := structured.Features{
458-
AdminAccess: pl.enableAdminAccess,
459-
PrioritizedList: pl.enablePrioritizedList,
460+
AdminAccess: pl.enableAdminAccess,
461+
PrioritizedList: pl.enablePrioritizedList,
462+
PartitionableDevices: pl.enablePartitionableDevices,
460463
DeviceTaints: pl.enableDeviceTaints,
461464
}
462465
allocator, err := structured.NewAllocator(ctx, features, allocateClaims, allAllocatedDevices, pl.draManager.DeviceClasses(), slices, pl.celCache)

pkg/scheduler/framework/plugins/feature/feature.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,5 +33,6 @@ type Features struct {
3333
EnableSchedulingQueueHint bool
3434
EnableAsyncPreemption bool
3535
EnablePodLevelResources bool
36+
EnablePartitionableDevices bool
3637
EnableStorageCapacityScoring bool
3738
}

pkg/scheduler/framework/plugins/registry.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@ func NewInTreeRegistry() runtime.Registry {
5959
EnableSchedulingQueueHint: feature.DefaultFeatureGate.Enabled(features.SchedulerQueueingHints),
6060
EnableAsyncPreemption: feature.DefaultFeatureGate.Enabled(features.SchedulerAsyncPreemption),
6161
EnablePodLevelResources: feature.DefaultFeatureGate.Enabled(features.PodLevelResources),
62+
EnablePartitionableDevices: feature.DefaultFeatureGate.Enabled(features.DRAPartitionableDevices),
6263
EnableStorageCapacityScoring: feature.DefaultFeatureGate.Enabled(features.StorageCapacityScoring),
6364
}
6465

staging/src/k8s.io/dynamic-resource-allocation/resourceslice/resourceslicecontroller.go

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,9 @@ type Pool struct {
141141
// Slice is turned into one ResourceSlice by the controller.
142142
type Slice struct {
143143
// Devices lists all devices which are part of the slice.
144-
Devices []resourceapi.Device
144+
Devices []resourceapi.Device
145+
SharedCounters []resourceapi.CounterSet
146+
PerDeviceNodeSelection *bool
145147
}
146148

147149
// +k8s:deepcopy-gen=true
@@ -548,7 +550,9 @@ func (c *Controller) syncPool(ctx context.Context, poolName string) error {
548550
if !apiequality.Semantic.DeepEqual(&currentSlice.Spec.Pool, &desiredPool) ||
549551
!apiequality.Semantic.DeepEqual(currentSlice.Spec.NodeSelector, pool.NodeSelector) ||
550552
currentSlice.Spec.AllNodes != desiredAllNodes ||
551-
!DevicesDeepEqual(currentSlice.Spec.Devices, pool.Slices[i].Devices) {
553+
!DevicesDeepEqual(currentSlice.Spec.Devices, pool.Slices[i].Devices) ||
554+
!apiequality.Semantic.DeepEqual(currentSlice.Spec.SharedCounters, pool.Slices[i].SharedCounters) ||
555+
!apiequality.Semantic.DeepEqual(currentSlice.Spec.PerDeviceNodeSelection, pool.Slices[i].PerDeviceNodeSelection) {
552556
changedDesiredSlices.Insert(i)
553557
logger.V(5).Info("Need to update slice", "slice", klog.KObj(currentSlice), "matchIndex", i)
554558
}
@@ -588,6 +592,8 @@ func (c *Controller) syncPool(ctx context.Context, poolName string) error {
588592
// have listed the existing slice.
589593
slice.Spec.NodeSelector = pool.NodeSelector
590594
slice.Spec.AllNodes = desiredAllNodes
595+
slice.Spec.SharedCounters = pool.Slices[i].SharedCounters
596+
slice.Spec.PerDeviceNodeSelection = pool.Slices[i].PerDeviceNodeSelection
591597
// Preserve TimeAdded from existing device, if there is a matching device and taint.
592598
slice.Spec.Devices = copyTaintTimeAdded(slice.Spec.Devices, pool.Slices[i].Devices)
593599

@@ -639,12 +645,14 @@ func (c *Controller) syncPool(ctx context.Context, poolName string) error {
639645
GenerateName: generateName,
640646
},
641647
Spec: resourceapi.ResourceSliceSpec{
642-
Driver: c.driverName,
643-
Pool: desiredPool,
644-
NodeName: nodeName,
645-
NodeSelector: pool.NodeSelector,
646-
AllNodes: desiredAllNodes,
647-
Devices: pool.Slices[i].Devices,
648+
Driver: c.driverName,
649+
Pool: desiredPool,
650+
NodeName: nodeName,
651+
NodeSelector: pool.NodeSelector,
652+
AllNodes: desiredAllNodes,
653+
Devices: pool.Slices[i].Devices,
654+
SharedCounters: pool.Slices[i].SharedCounters,
655+
PerDeviceNodeSelection: pool.Slices[i].PerDeviceNodeSelection,
648656
},
649657
}
650658

0 commit comments

Comments
 (0)