Skip to content

Commit 90a4556

Browse files
authored
Merge pull request kubernetes#129517 from googs1025/feature/remove/dra_resourceslice_qhint
feature(scheduler): remove dra plugin resourceslice QueueingHintFn
2 parents 4ab6035 + 77eae7c commit 90a4556

File tree

2 files changed

+1
-138
lines changed

2 files changed

+1
-138
lines changed

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

Lines changed: 1 addition & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,7 @@ func (pl *DynamicResources) EventsToRegister(_ context.Context) ([]framework.Clu
176176
// A pod might be waiting for a class to get created or modified.
177177
{Event: framework.ClusterEvent{Resource: framework.DeviceClass, ActionType: framework.Add | framework.Update}},
178178
// Adding or updating a ResourceSlice might make a pod schedulable because new resources became available.
179-
{Event: framework.ClusterEvent{Resource: framework.ResourceSlice, ActionType: framework.Add | framework.Update}, QueueingHintFn: pl.isSchedulableAfterResourceSliceChange},
179+
{Event: framework.ClusterEvent{Resource: framework.ResourceSlice, ActionType: framework.Add | framework.Update}},
180180
}
181181

182182
return events, nil
@@ -288,38 +288,6 @@ func (pl *DynamicResources) isSchedulableAfterPodChange(logger klog.Logger, pod
288288
return framework.Queue, nil
289289
}
290290

291-
// isSchedulableAfterResourceSliceChange is invoked for add and update slice events reported by
292-
// an informer. Such changes can make an unschedulable pod schedulable when the pod requests a device
293-
// and the change adds a suitable device.
294-
//
295-
// For the sake of faster execution and avoiding code duplication, isSchedulableAfterResourceSliceChange
296-
// only checks whether the pod uses claims. All of the more detailed checks are done in the scheduling
297-
// attempt.
298-
//
299-
// The delete claim event will not invoke it, so newObj will never be nil.
300-
func (pl *DynamicResources) isSchedulableAfterResourceSliceChange(logger klog.Logger, pod *v1.Pod, oldObj, newObj interface{}) (framework.QueueingHint, error) {
301-
_, modifiedSlice, err := schedutil.As[*resourceapi.ResourceSlice](oldObj, newObj)
302-
if err != nil {
303-
// Shouldn't happen.
304-
return framework.Queue, fmt.Errorf("unexpected object in isSchedulableAfterResourceSliceChange: %w", err)
305-
}
306-
307-
if err := pl.foreachPodResourceClaim(pod, nil); err != nil {
308-
// This is not an unexpected error: we know that
309-
// foreachPodResourceClaim only returns errors for "not
310-
// schedulable".
311-
logger.V(6).Info("pod is not schedulable after resource slice change", "pod", klog.KObj(pod), "resourceSlice", klog.KObj(modifiedSlice), "reason", err.Error())
312-
return framework.QueueSkip, nil
313-
}
314-
315-
// We could check what got changed in the slice, but right now that's likely to be
316-
// about the spec (there's no status yet...).
317-
// We could check whether all claims use classic DRA, but that doesn't seem worth it.
318-
// Let's assume that changing the slice may make the pod schedulable.
319-
logger.V(5).Info("ResourceSlice change might make pod schedulable", "pod", klog.KObj(pod), "resourceSlice", klog.KObj(modifiedSlice))
320-
return framework.Queue, nil
321-
}
322-
323291
// podResourceClaims returns the ResourceClaims for all pod.Spec.PodResourceClaims.
324292
func (pl *DynamicResources) podResourceClaims(pod *v1.Pod) ([]*resourceapi.ResourceClaim, error) {
325293
claims := make([]*resourceapi.ResourceClaim, 0, len(pod.Spec.ResourceClaims))

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

Lines changed: 0 additions & 105 deletions
Original file line numberDiff line numberDiff line change
@@ -1412,108 +1412,3 @@ func Test_isSchedulableAfterPodChange(t *testing.T) {
14121412
})
14131413
}
14141414
}
1415-
1416-
func Test_isSchedulableAfterResourceSliceChange(t *testing.T) {
1417-
testcases := map[string]struct {
1418-
pod *v1.Pod
1419-
claims []*resourceapi.ResourceClaim
1420-
oldObj, newObj interface{}
1421-
wantHint framework.QueueingHint
1422-
wantErr bool
1423-
}{
1424-
"queue-new-resource-slice": {
1425-
pod: podWithClaimName,
1426-
claims: []*resourceapi.ResourceClaim{pendingClaim},
1427-
newObj: resourceSlice,
1428-
wantHint: framework.Queue,
1429-
},
1430-
"queue1-update-resource-slice-with-claim-is-allocated": {
1431-
pod: podWithClaimName,
1432-
claims: []*resourceapi.ResourceClaim{allocatedClaim},
1433-
oldObj: resourceSlice,
1434-
newObj: resourceSliceUpdated,
1435-
wantHint: framework.Queue,
1436-
},
1437-
"queue-update-resource-slice-with-claim-is-deleting": {
1438-
pod: podWithClaimName,
1439-
claims: []*resourceapi.ResourceClaim{deleteClaim},
1440-
oldObj: resourceSlice,
1441-
newObj: resourceSliceUpdated,
1442-
wantHint: framework.QueueSkip,
1443-
},
1444-
"queue-new-resource-slice-with-two-claim": {
1445-
pod: podWithTwoClaimNames,
1446-
claims: []*resourceapi.ResourceClaim{pendingClaim, pendingClaim2},
1447-
oldObj: resourceSlice,
1448-
newObj: resourceSliceUpdated,
1449-
wantHint: framework.Queue,
1450-
},
1451-
"queue-update-resource-slice-with-two-claim-but-one-hasn't-been-created": {
1452-
pod: podWithTwoClaimNames,
1453-
claims: []*resourceapi.ResourceClaim{pendingClaim},
1454-
oldObj: resourceSlice,
1455-
newObj: resourceSliceUpdated,
1456-
wantHint: framework.QueueSkip,
1457-
},
1458-
"queue-update-resource-slice": {
1459-
pod: podWithClaimName,
1460-
claims: []*resourceapi.ResourceClaim{pendingClaim},
1461-
oldObj: resourceSlice,
1462-
newObj: resourceSliceUpdated,
1463-
wantHint: framework.Queue,
1464-
},
1465-
"skip-not-find-resource-claim": {
1466-
pod: podWithClaimName,
1467-
claims: []*resourceapi.ResourceClaim{},
1468-
oldObj: resourceSlice,
1469-
newObj: resourceSliceUpdated,
1470-
wantHint: framework.QueueSkip,
1471-
},
1472-
"backoff-unexpected-object-with-oldObj-newObj": {
1473-
pod: podWithClaimName,
1474-
claims: []*resourceapi.ResourceClaim{pendingClaim},
1475-
oldObj: pendingClaim,
1476-
newObj: pendingClaim,
1477-
wantErr: true,
1478-
},
1479-
"backoff-unexpected-object-with-oldObj": {
1480-
pod: podWithClaimName,
1481-
claims: []*resourceapi.ResourceClaim{pendingClaim},
1482-
oldObj: pendingClaim,
1483-
newObj: resourceSlice,
1484-
wantErr: true,
1485-
},
1486-
"backoff-unexpected-object-with-newObj": {
1487-
pod: podWithClaimName,
1488-
claims: []*resourceapi.ResourceClaim{pendingClaim},
1489-
oldObj: resourceSlice,
1490-
newObj: pendingClaim,
1491-
wantErr: true,
1492-
},
1493-
}
1494-
for name, tc := range testcases {
1495-
tc := tc
1496-
t.Run(name, func(t *testing.T) {
1497-
t.Parallel()
1498-
logger, _ := ktesting.NewTestContext(t)
1499-
features := feature.Features{
1500-
EnableDynamicResourceAllocation: true,
1501-
}
1502-
testCtx := setup(t, nil, tc.claims, nil, nil, features)
1503-
gotHint, err := testCtx.p.isSchedulableAfterResourceSliceChange(logger, tc.pod, tc.oldObj, tc.newObj)
1504-
if tc.wantErr {
1505-
if err == nil {
1506-
t.Fatal("want an error, got none")
1507-
}
1508-
return
1509-
}
1510-
1511-
if err != nil {
1512-
t.Fatalf("want no error, got: %v", err)
1513-
}
1514-
if tc.wantHint != gotHint {
1515-
t.Fatalf("want %#v, got %#v", tc.wantHint.String(), gotHint.String())
1516-
}
1517-
})
1518-
}
1519-
}

0 commit comments

Comments
 (0)