in pkg/controllers/job/job_controller_handler.go [290:356]
func (cc *jobcontroller) deletePod(obj interface{}) {
pod, ok := obj.(*v1.Pod)
if !ok {
// If we reached here it means the pod was deleted but its final state is unrecorded.
tombstone, ok := obj.(cache.DeletedFinalStateUnknown)
if !ok {
klog.Errorf("Couldn't get object from tombstone %#v", obj)
return
}
pod, ok = tombstone.Obj.(*v1.Pod)
if !ok {
klog.Errorf("Tombstone contained object that is not a Pod: %#v", obj)
return
}
}
// Filter out pods that are not created from volcano job
if !isControlledBy(pod, helpers.JobKind) {
return
}
taskName, found := pod.Annotations[batch.TaskSpecKey]
if !found {
klog.Infof("Failed to find taskName of Pod <%s/%s>, skipping",
pod.Namespace, pod.Name)
return
}
jobName, found := pod.Annotations[batch.JobNameKey]
if !found {
klog.Infof("Failed to find jobName of Pod <%s/%s>, skipping",
pod.Namespace, pod.Name)
return
}
version, found := pod.Annotations[batch.JobVersion]
if !found {
klog.Infof("Failed to find jobVersion of Pod <%s/%s>, skipping",
pod.Namespace, pod.Name)
return
}
dVersion, err := strconv.Atoi(version)
if err != nil {
klog.Infof("Failed to convert jobVersion of Pod <%s/%s> into number, skipping",
pod.Namespace, pod.Name)
return
}
req := apis.Request{
Namespace: pod.Namespace,
JobName: jobName,
TaskName: taskName,
Event: bus.PodEvictedEvent,
JobVersion: int32(dVersion),
}
if err := cc.cache.DeletePod(pod); err != nil {
klog.Errorf("Failed to delete Pod <%s/%s>: %v in cache",
pod.Namespace, pod.Name, err)
}
key := jobhelpers.GetJobKeyByReq(&req)
queue := cc.getWorkerQueue(key)
queue.Add(req)
}