Skip to content

Commit 3210a84

Browse files
Fix: Set Requeued condition for standalone workloads during admission check eviction
Previously, only job-managed workloads had the Requeued condition set during admission check eviction (via jobframework). Standalone workloads had no code path setting this condition. This change adds the condition to standalone workloads, ensuring consistent behavior between job-managed and standalone workloads. Signed-off-by: Sohan Kunkerkar <[email protected]>
1 parent cc40ec1 commit 3210a84

File tree

2 files changed

+23
-3
lines changed

2 files changed

+23
-3
lines changed

pkg/controller/core/workload_controller.go

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -289,8 +289,14 @@ func (r *WorkloadReconciler) Reconcile(ctx context.Context, req ctrl.Request) (c
289289
if wl.Status.RequeueState != nil && wl.Status.RequeueState.RequeueAt != nil {
290290
requeueAfter := ptr.To(wl.Status.RequeueState.RequeueAt.Sub(r.clock.Now()))
291291
if requeueAfter != nil && *requeueAfter > 0 {
292-
log.V(3).Info("Waiting for backoff to finish", "backoff", *requeueAfter)
293-
return reconcile.Result{RequeueAfter: *requeueAfter}, nil
292+
// If the workload has retry checks and is not yet evicted (Pending),
293+
// we should proceed to eviction instead of waiting.
294+
if workload.HasRetryChecks(&wl) && workload.Status(&wl) != workload.StatusPending {
295+
log.V(3).Info("Skipping backoff wait to proceed with eviction", "requeueAfter", *requeueAfter)
296+
} else {
297+
log.V(3).Info("Waiting for backoff to finish", "backoff", *requeueAfter)
298+
return reconcile.Result{RequeueAfter: *requeueAfter}, nil
299+
}
294300
}
295301

296302
if workload.Status(&wl) == workload.StatusPending {
@@ -601,7 +607,15 @@ func (r *WorkloadReconciler) reconcileCheckBasedEviction(ctx context.Context, wl
601607
}
602608
// at this point we know a Workload has at least one Retry AdmissionCheck
603609
message := "At least one admission check is false"
604-
if err := workload.Evict(ctx, r.client, r.recorder, wl, kueue.WorkloadEvictedByAdmissionCheck, message, "", r.clock); err != nil {
610+
// Calculate the retry time from admission checks before eviction resets them.
611+
maxRetryTime := workload.GetMaxRetryTime(wl)
612+
if err := workload.Evict(ctx, r.client, r.recorder, wl, kueue.WorkloadEvictedByAdmissionCheck, message, "", r.clock, workload.WithCustomPrepare(func(wl *kueue.Workload) {
613+
// Set Requeued=false to track eviction, matching jobframework behavior
614+
workload.SetRequeuedCondition(wl, kueue.WorkloadEvictedByAdmissionCheck, "Evicted due to admission check retry", false)
615+
if !maxRetryTime.IsZero() {
616+
workload.SetRequeueState(wl, maxRetryTime, false)
617+
}
618+
})); err != nil {
605619
return false, err
606620
}
607621
return true, nil

pkg/controller/core/workload_controller_test.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -981,6 +981,12 @@ func TestReconcile(t *testing.T) {
981981
Reason: "AdmissionCheck",
982982
Message: "At least one admission check is false",
983983
}).
984+
Condition(metav1.Condition{
985+
Type: "Requeued",
986+
Status: "False",
987+
Reason: "AdmissionCheck",
988+
Message: "Evicted due to admission check retry",
989+
}).
984990
SchedulingStatsEviction(
985991
kueue.WorkloadSchedulingStatsEviction{
986992
Reason: kueue.WorkloadEvictedByAdmissionCheck,

0 commit comments

Comments
 (0)