Skip to content

Commit 3d8d8fb

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 3d8d8fb

File tree

2 files changed

+15
-12
lines changed

2 files changed

+15
-12
lines changed

pkg/controller/core/workload_controller.go

Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -205,17 +205,6 @@ func (r *WorkloadReconciler) Reconcile(ctx context.Context, req ctrl.Request) (c
205205
return ctrl.Result{}, nil
206206
}
207207

208-
if requeueAt := workload.NeedsRequeueAtUpdate(&wl, r.clock); requeueAt != nil {
209-
err := workload.PatchAdmissionStatus(ctx, r.client, &wl, r.clock, func(wl *kueue.Workload) (bool, error) {
210-
if wl.Status.RequeueState == nil {
211-
wl.Status.RequeueState = &kueue.RequeueState{}
212-
}
213-
log.V(2).Info("At least one admission check set a retry time", "requeueAt", requeueAt, "current", wl.Status.RequeueState.RequeueAt)
214-
workload.SetRequeueState(wl, *requeueAt, false)
215-
return true, nil
216-
})
217-
return reconcile.Result{}, client.IgnoreNotFound(err)
218-
}
219208
if features.Enabled(features.DynamicResourceAllocation) && workload.Status(&wl) == workload.StatusPending &&
220209
workload.HasDRA(&wl) {
221210
workload.AdjustResources(ctx, r.client, &wl)
@@ -601,7 +590,15 @@ func (r *WorkloadReconciler) reconcileCheckBasedEviction(ctx context.Context, wl
601590
}
602591
// at this point we know a Workload has at least one Retry AdmissionCheck
603592
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 {
593+
// Calculate the retry time from admission checks before eviction resets them.
594+
maxRetryTime := workload.GetMaxRetryTime(wl)
595+
if err := workload.Evict(ctx, r.client, r.recorder, wl, kueue.WorkloadEvictedByAdmissionCheck, message, "", r.clock, workload.WithCustomPrepare(func(wl *kueue.Workload) {
596+
// Set Requeued=false to track eviction, matching jobframework behavior
597+
workload.SetRequeuedCondition(wl, kueue.WorkloadEvictedByAdmissionCheck, "Evicted due to admission check retry", false)
598+
if !maxRetryTime.IsZero() {
599+
workload.SetRequeueState(wl, maxRetryTime, false)
600+
}
601+
})); err != nil {
605602
return false, err
606603
}
607604
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)