Skip to content

Commit

Permalink
updated workload controller to use unuused quota
Browse files Browse the repository at this point in the history
  • Loading branch information
vicentefb committed Apr 24, 2024
1 parent 9e2a16f commit 60cbf6b
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion pkg/controller/core/workload_controller.go
Expand Up @@ -255,6 +255,16 @@ func (r *WorkloadReconciler) Reconcile(ctx context.Context, req ctrl.Request) (c
return ctrl.Result{}, nil
}

func (r *WorkloadReconciler) isScaledDown(wl *kueue.Workload) bool {
podSetSize := len(wl.Spec.PodSets)
for i := 1; i < podSetSize; i++ {
if ptr.Deref(wl.Status.Admission.PodSetAssignments[i].Count, 0) > wl.Spec.PodSets[i].Count {
return true
}
}
return false
}

func (r *WorkloadReconciler) downSizeJobIfNecessary(wl *kueue.Workload, ctx context.Context) error {
statusUpdate := false
podSetSize := len(wl.Spec.PodSets)
Expand Down Expand Up @@ -528,6 +538,7 @@ func (r *WorkloadReconciler) Delete(e event.DeleteEvent) bool {

func (r *WorkloadReconciler) Update(e event.UpdateEvent) bool {
oldWl, isWorkload := e.ObjectOld.(*kueue.Workload)

if !isWorkload {
// this event will be handled by the LimitRange/RuntimeClass handle
return true
Expand Down Expand Up @@ -620,7 +631,7 @@ func (r *WorkloadReconciler) Update(e event.UpdateEvent) bool {
}
})
}
case prevStatus == admitted && status == admitted && !equality.Semantic.DeepEqual(oldWl.Status.ReclaimablePods, wl.Status.ReclaimablePods):
case prevStatus == admitted && status == admitted && !equality.Semantic.DeepEqual(oldWl.Status.ReclaimablePods, wl.Status.ReclaimablePods) || r.isScaledDown(oldWl):
// trigger the move of associated inadmissibleWorkloads, if there are any.
r.queues.QueueAssociatedInadmissibleWorkloadsAfter(ctx, wl, func() {
// Update the workload from cache while holding the queues lock
Expand Down

0 comments on commit 60cbf6b

Please sign in to comment.