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:29:00 UTC
[jira] [Created] (YUNIKORN-3534) Delete the Foreign Pod in the Shim When Preempted
Aditya Maheshwari created YUNIKORN-3534:
-------------------------------------------
Summary: Delete the Foreign Pod in the Shim When Preempted
Key: YUNIKORN-3534
URL: https://issues.apache.org/jira/browse/YUNIKORN-3534
Project: Apache YuniKorn
Issue Type: Sub-task
Components: shim - kubernetes
Reporter: Aditya Maheshwari
Assignee: Aditya Maheshwari
This is the most critical change on the shim side. Currently, when {{yunikorn-core}} sends {{notifyRMAllocationReleased}} ({{{}TerminationType_PREEMPTED_BY_SCHEDULER{}}}), {{AsyncRMCallback.UpdateAllocation}} does:
{{for _, release := range response.Released \{ callback.context.ForgetPod(release.GetAllocationKey()) if release.TerminationType != si.TerminationType_STOPPED_BY_RM { ev := NewReleaseAppAllocationEvent(release.ApplicationID, release.TerminationType, release.AllocationKey) dispatcher.Dispatch(ev) } }}}{{}}
For a foreign pod:
# {{release.ApplicationID}} is {*}{{""}} (empty){*}.
# The dispatcher looks up the {{Application}} by {{{}ApplicationID == ""{}}}, fails to find it, and {*}drops the event{*}, so the foreign pod is {*}never deleted from Kubernetes{*}!
# Furthermore, calling {{callback.context.ForgetPod(release.GetAllocationKey())}} before deleting the pod removes it from {{schedulerCache.podsMap}} immediately!
*Required Changes in {{{}yunikorn-k8shim{}}}:*
# {*}In {{scheduler_callback.go}}{*}:
** Check if {{release.ApplicationID == ""}} (or if the pod is a foreign pod):{{{}if release.ApplicationID == "" \{
if release.TerminationType != si.TerminationType_STOPPED_BY_RM {
callback.context.PreemptForeignPod(release.AllocationKey)
}
continue
}{}}}
# {*}Add {{PreemptForeignPod(allocationKey string)}} on {{Context}} in {{context.go}}{*}:
** Look up the {{*v1.Pod}} from {{{}ctx.schedulerCache.GetPod(allocationKey){}}}.
** Optionally emit a Kubernetes event on the pod (e.g., {{{}events.GetRecorder().Eventf(pod.DeepCopy(), nil, v1.EventTypeNormal, "Preempted", "Preempted", "Pod preempted by YuniKorn scheduler"){}}}).
** Delete the pod from Kubernetes using {{{}ctx.apiProvider.GetAPIs().KubeClient.Delete(context.Background(), pod){}}}.
** *Do not* remove it from {{schedulerCache}} until Kubernetes confirms termination/deletion: when the pod actually terminates in K8s, the existing informer handlers ({{{}updateForeignPod{}}} / {{{}deleteForeignPod{}}}) will automatically remove the pod from {{schedulerCache}} and send {{CreateReleaseRequestForForeignPod}} ({{{}ApplicationID: ""{}}}, {{{}AllocationKey: uid{}}}) back to {{{}yunikorn-core{}}}, which triggers {{pc.removeForeignAllocation(allocationKey)}} and frees {{node.occupiedResource}} and {{{}node.availableResource{}}}.
--
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