Return Error from DRA filter on timeout to enable automatic retry

This commit is contained in:
Hamza
2026-03-11 02:20:30 +01:00
parent f98d927105
commit 0680960e5e
2 changed files with 7 additions and 5 deletions

View File

@@ -721,7 +721,10 @@ func (pl *DynamicResources) Filter(ctx context.Context, cs fwk.CycleState, pod *
a, err := state.allocator.Allocate(allocCtx, node, claimsToAllocate)
switch {
case errors.Is(err, context.DeadlineExceeded):
return statusUnschedulable(logger, "timed out trying to allocate devices", "pod", klog.KObj(pod), "node", klog.KObj(node), "resourceclaims", klog.KObjSlice(claimsToAllocate))
// Timeouts are transient, not a property of the node. Return Error
// so the pod retries via backoff instead of sitting in the
// unschedulable queue waiting for a cluster event.
return statusError(logger, fmt.Errorf("timed out trying to allocate devices"), "pod", klog.KObj(pod), "node", klog.KObj(node), "resourceclaims", klog.KObjSlice(claimsToAllocate))
case errors.Is(err, structured.ErrFailedAllocationOnNode):
// Not a fatal error, allocation on other nodes may proceed.
// The error is only surfaced if allocation fails on all nodes.

View File

@@ -2114,12 +2114,11 @@ func testPlugin(tCtx ktesting.TContext) {
want: want{
filter: perNodeResult{
workerNode.Name: {
status: fwk.NewStatus(fwk.UnschedulableAndUnresolvable, `timed out trying to allocate devices`),
// Timeouts return Error so the pod retries via backoff.
status: fwk.AsStatus(fmt.Errorf("timed out trying to allocate devices")),
},
},
postfilter: result{
status: fwk.NewStatus(fwk.Unschedulable, `still not schedulable`),
},
// No postfilter: Error aborts scheduling immediately.
},
// Skipping this test case on Windows as a 1ns timeout is not guaranteed to
// expire immediately on Windows due to its coarser timer granularity -