You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@yunikorn.apache.org by "Aditya Maheshwari (Jira)" <ji...@apache.org> on 2026/10/28 10:20:00 UTC

[jira] [Created] (YUNIKORN-3533) Include Foreign Allocations in Regular Node Preemption

Aditya Maheshwari created YUNIKORN-3533:
-------------------------------------------

             Summary: Include Foreign Allocations in Regular Node Preemption 
                 Key: YUNIKORN-3533
                 URL: https://issues.apache.org/jira/browse/YUNIKORN-3533
             Project: Apache YuniKorn
          Issue Type: Sub-task
          Components: core - scheduler
            Reporter: Aditya Maheshwari
            Assignee: Aditya Maheshwari


In {{{}preemption.go{}}}, {{Preemptor}} currently assumes every victim comes from a {{QueuePreemptionSnapshot}} ({{{}p.allocationsByQueue{}}} and {{{}p.queueByAlloc{}}}). Because foreign pods are not in any queue, four places in {{preemption.go}} need updates:
h4. A. Collect Foreign Victims per Node in {{initWorkingState}}

When walking nodes in {{{}p.iterator.ForEachNode(...){}}}:
 * If the node is schedulable, not reserved, and fits the ask's total capacity ({{{}node.FitInNode(...){}}}), also inspect {{{}node.GetForeignAllocations(){}}}:
 ** Filter each foreign allocation {{{}alloc{}}}:
 *** {{alloc.IsPreemptable()}} must be {{true}} (not a static pod).
 *** {{alloc.GetRequiredNode() == ""}} (not a DaemonSet pod).
 *** {{!alloc.IsPreempted()}} and {{{}!alloc.IsReleased(){}}}.
 *** {{p.ask.GetAllocatedResource().MatchAny(alloc.GetAllocatedResource())}} (shares at least one resource type).
 *** {{alloc.GetPriority() < p.ask.GetPriority()}} ({*}strictly lower priority{*} than the preemptor pod).
 ** Append matching foreign allocations to {{{}allocationsByNode[node.NodeID]{}}}. (Do *not* add them to {{queueByAlloc}} since they have no queue).
 * Note on {{{}sortVictimsForPreemption{}}}: Consider whether you want foreign pods to be preferred over YuniKorn pods, or sorted purely alongside them by {{{}(Originator, AllowPreemptSelf, Priority, CreateTime){}}}. Note that currently {{sortVictimsForPreemption}} does not sort by priority (only {{SortAllocationsBasedOnAsk}} does), so adding a priority comparison or foreign preference in {{sortVictimsForPreemption}} ensures lower-priority foreign pods are picked in the right order.

h4. B. Handle Queue-less (Foreign) Victims in {{calculateVictimsByNode}}

Currently, Pass 1 and Pass 2 in {{calculateVictimsByNode}} only consider a victim if {{qv, ok := p.queueByAlloc[victim.GetAllocationKey()]}} is true:
 * Update both passes in {{{}calculateVictimsByNode{}}}:
 ** {*}If {{victim.IsForeign()}}{*}: It has no queue guaranteed constraints to violate. Directly check if removing {{victim}} reduces the node shortfall ({{{}shortfall{}}} vs {{{}newShortfall{}}}). If it reduces the shortfall, add to {{head}} and add its resources to {{{}nodeCurrentAvailable{}}}; otherwise add to {{{}tail{}}}. In Pass 2, directly add {{victim.GetAllocatedResource()}} to {{{}nodeCurrentAvailable{}}}, update {{index}} if {{{}nodeCurrentAvailable.FitIn(p.ask.GetAllocatedResource()){}}}, and append {{victim}} to {{{}results{}}}.

h4. C. Distinguish Node vs. Queue Resource Contributions in {{TryPreemption}} & {{hasPreemptionShortfall}}
 * Preempting a foreign pod frees *node* resources ({{{}nodeVictimsResource{}}}), but *does not free queue headroom* ({{{}totalVictimsResource{}}} for queue quota).
 * In {{{}TryPreemption{}}}:
 ** When iterating {{{}nodeVictims{}}}, always add {{victim.GetAllocatedResource()}} to {{{}nodeVictimsResource{}}}, but *only* add to {{totalVictimsResource}} (queue resource freed) if {{{}!victim.IsForeign(){}}}.
 * When committing the victims in {{{}TryPreemption{}}}:
 ** Guard {{p.queue.GetQueueByAppID(victim.GetApplicationID())}} and {{victim.SendPreemptedBySchedulerEvent(...)}} with {{{}if !victim.IsForeign(){}}}, because foreign pods have no {{ApplicationID}} or {{{}Queue{}}}.



--
This message was sent by Atlassian Jira
(v10.3.26#10030026)

---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@yunikorn.apache.org
For additional commands, e-mail: issues-help@yunikorn.apache.org