Skip to content

Commit

Permalink
[ctrl/workload] Preserve the preemption AC status
Browse files Browse the repository at this point in the history
  • Loading branch information
trasc committed Sep 14, 2023
1 parent 9d8fdf7 commit 561228c
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions pkg/controller/core/workload_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ import (

kueue "sigs.k8s.io/kueue/apis/kueue/v1beta1"
"sigs.k8s.io/kueue/pkg/cache"
"sigs.k8s.io/kueue/pkg/constants"
"sigs.k8s.io/kueue/pkg/controller/core/indexer"
"sigs.k8s.io/kueue/pkg/queue"
"sigs.k8s.io/kueue/pkg/util/limitrange"
Expand Down Expand Up @@ -194,11 +195,16 @@ func (r *WorkloadReconciler) reconcileSyncAdmissionChecks(ctx context.Context, w
return false, err
}

queueAdmissionChecks := queue.Spec.AdmissionChecks
newChecks, shouldUpdate := syncAdmissionCheckConditions(wl.Status.AdmissionChecks, queueAdmissionChecks)
targetChecks := queue.Spec.AdmissionChecks
// preserve the preemption check if necessary
if pc := apimeta.FindStatusCondition(wl.Status.AdmissionChecks, constants.PreemptionAdmissionCheckName); pc != nil && apimeta.IsStatusConditionTrue(wl.Status.Conditions, kueue.WorkloadQuotaReserved) {
targetChecks = append(targetChecks, constants.PreemptionAdmissionCheckName)
}

newChecks, shouldUpdate := syncAdmissionCheckConditions(wl.Status.AdmissionChecks, targetChecks)
if shouldUpdate {
log := ctrl.LoggerFrom(ctx)
log.V(3).Info("The workload needs admission checks updates", "clusterQueue", klog.KRef("", cqName), "admissionChecks", queueAdmissionChecks)
log.V(3).Info("The workload needs admission checks updates", "clusterQueue", klog.KRef("", cqName), "admissionChecks", targetChecks)
wl.Status.AdmissionChecks = newChecks
err := r.client.Status().Update(ctx, wl)
return true, client.IgnoreNotFound(err)
Expand Down

0 comments on commit 561228c

Please sign in to comment.