Skip to content

Commit 6ea3123

Browse files
committed
[YUNIKORN-3274] Remove code: Clean up task directory in shim repo (#1023)
Closes: #1023 Signed-off-by: Manikandan R <manirajv06@gmail.com>
1 parent 214a23d commit 6ea3123

1 file changed

Lines changed: 27 additions & 50 deletions

File tree

pkg/cache/task.go

Lines changed: 27 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -352,50 +352,34 @@ func (task *Task) postTaskAllocated() {
352352
task.lock.Lock()
353353
defer task.lock.Unlock()
354354

355-
// plugin mode means we delegate this work to the default scheduler
356-
if utils.IsPluginMode() {
357-
log.Log(log.ShimCacheTask).Debug("allocating pod",
358-
zap.String("podName", task.pod.Name),
359-
zap.String("podUID", string(task.pod.UID)))
360-
361-
task.context.AddPendingPodAllocation(string(task.pod.UID), task.nodeName)
362-
363-
dispatcher.Dispatch(NewBindTaskEvent(task.applicationID, task.taskID))
364-
events.GetRecorder().Eventf(task.pod.DeepCopy(),
365-
nil, v1.EventTypeNormal, "Pending", "Pending",
366-
"Pod %s is ready for scheduling on node %s", task.alias, task.nodeName)
367-
} else {
368-
// post a message to indicate the pod gets its allocation
369-
events.GetRecorder().Eventf(task.pod.DeepCopy(),
370-
nil, v1.EventTypeNormal, "Scheduled", "Scheduled",
371-
"Successfully assigned %s to node %s", task.alias, task.nodeName)
372-
373-
// before binding pod to node, first bind volumes to pod
374-
log.Log(log.ShimCacheTask).Debug("bind pod volumes",
375-
zap.String("podName", task.pod.Name),
376-
zap.String("podUID", string(task.pod.UID)))
377-
if err := task.context.bindPodVolumes(task.pod); err != nil {
378-
log.Log(log.ShimCacheTask).Error("bind volumes to pod failed", zap.String("taskID", task.taskID), zap.Error(err))
379-
task.failWithEvent(fmt.Sprintf("bind volumes to pod failed, name: %s, %s", task.alias, err.Error()), "PodVolumesBindFailure")
380-
return
381-
}
382-
383-
log.Log(log.ShimCacheTask).Debug("bind pod",
384-
zap.String("podName", task.pod.Name),
385-
zap.String("podUID", string(task.pod.UID)))
386-
387-
if err := task.context.apiProvider.GetAPIs().KubeClient.Bind(task.pod, task.nodeName); err != nil {
388-
log.Log(log.ShimCacheTask).Error("bind pod to node failed", zap.String("taskID", task.taskID), zap.Error(err))
389-
task.failWithEvent(fmt.Sprintf("bind pod to node failed, name: %s, %s", task.alias, err.Error()), "PodBindFailure")
390-
return
391-
}
392-
393-
log.Log(log.ShimCacheTask).Info("successfully bound pod", zap.String("podName", task.pod.Name))
394-
dispatcher.Dispatch(NewBindTaskEvent(task.applicationID, task.taskID))
395-
events.GetRecorder().Eventf(task.pod.DeepCopy(), nil,
396-
v1.EventTypeNormal, "PodBindSuccessful", "PodBindSuccessful",
397-
"Pod %s is successfully bound to node %s", task.alias, task.nodeName)
355+
// post a message to indicate the pod gets its allocation
356+
events.GetRecorder().Eventf(task.pod.DeepCopy(),
357+
nil, v1.EventTypeNormal, "Scheduled", "Scheduled",
358+
"Successfully assigned %s to node %s", task.alias, task.nodeName)
359+
360+
// before binding pod to node, first bind volumes to pod
361+
log.Log(log.ShimCacheTask).Debug("bind pod volumes",
362+
zap.String("podName", task.pod.Name),
363+
zap.String("podUID", string(task.pod.UID)))
364+
if err := task.context.bindPodVolumes(task.pod); err != nil {
365+
log.Log(log.ShimCacheTask).Error("bind volumes to pod failed", zap.String("taskID", task.taskID), zap.Error(err))
366+
task.failWithEvent(fmt.Sprintf("bind volumes to pod failed, name: %s, %s", task.alias, err.Error()), "PodVolumesBindFailure")
367+
return
368+
}
369+
log.Log(log.ShimCacheTask).Debug("bind pod",
370+
zap.String("podName", task.pod.Name),
371+
zap.String("podUID", string(task.pod.UID)))
372+
373+
if err := task.context.apiProvider.GetAPIs().KubeClient.Bind(task.pod, task.nodeName); err != nil {
374+
log.Log(log.ShimCacheTask).Error("bind pod to node failed", zap.String("taskID", task.taskID), zap.Error(err))
375+
task.failWithEvent(fmt.Sprintf("bind pod to node failed, name: %s, %s", task.alias, err.Error()), "PodBindFailure")
376+
return
398377
}
378+
log.Log(log.ShimCacheTask).Info("successfully bound pod", zap.String("podName", task.pod.Name))
379+
dispatcher.Dispatch(NewBindTaskEvent(task.applicationID, task.taskID))
380+
events.GetRecorder().Eventf(task.pod.DeepCopy(), nil,
381+
v1.EventTypeNormal, "PodBindSuccessful", "PodBindSuccessful",
382+
"Pod %s is successfully bound to node %s", task.alias, task.nodeName)
399383

400384
task.schedulingState = TaskSchedAllocated
401385
}()
@@ -425,13 +409,6 @@ func (task *Task) beforeTaskAllocated(eventSrc string, allocationKey string, nod
425409
}
426410

427411
func (task *Task) postTaskBound() {
428-
if utils.IsPluginMode() {
429-
// When the pod is actively scheduled by YuniKorn, it can be moved to the default-scheduler's
430-
// UnschedulablePods structure. If the pod does not change, the pod will stay in the UnschedulablePods
431-
// structure for podMaxInUnschedulablePodsDuration (default 5 minutes). Here we explicitly activate the pod.
432-
task.context.ActivatePod(task.pod)
433-
}
434-
435412
if task.placeholder {
436413
log.Log(log.ShimCacheTask).Info("placeholder is bound",
437414
zap.String("appID", task.applicationID),

0 commit comments

Comments
 (0)