wilfred-s commented on code in PR #873:
URL: https://github.com/apache/yunikorn-k8shim/pull/873#discussion_r1701158983


##########
pkg/cache/context.go:
##########
@@ -315,7 +315,9 @@ func (ctx *Context) updateYuniKornPod(appID string, pod 
*v1.Pod) {
 
        // treat terminated pods like a remove
        if utils.IsPodTerminated(pod) {
-               ctx.notifyTaskComplete(appID, taskID)
+               if app != nil {

Review Comment:
   Lets clean up a bit more: the line 310 we retrieve the app inside the if and 
we have a separate declaration of the var in 308. We can fold the two into one 
by retrieving the app outside the if:
   ```
   app := ctx.getApplication(appID)
   if app != nil {
   ```



##########
pkg/cache/context.go:
##########
@@ -908,25 +910,23 @@ func (ctx *Context) StartPodAllocation(podKey string, 
nodeID string) bool {
        return ctx.schedulerCache.StartPodAllocation(podKey, nodeID)
 }
 
-func (ctx *Context) NotifyTaskComplete(appID, taskID string) {
+func (ctx *Context) NotifyTaskComplete(app *Application, taskID string) {
        ctx.lock.Lock()
        defer ctx.lock.Unlock()
-       ctx.notifyTaskComplete(appID, taskID)
+       ctx.notifyTaskComplete(app, taskID)
 }
 
-func (ctx *Context) notifyTaskComplete(appID, taskID string) {
+func (ctx *Context) notifyTaskComplete(app *Application, taskID string) {
        log.Log(log.ShimContext).Debug("NotifyTaskComplete",
-               zap.String("appID", appID),
+               zap.String("appID", app.applicationID),
                zap.String("taskID", taskID))
-       if app := ctx.getApplication(appID); app != nil {
-               log.Log(log.ShimContext).Debug("release allocation",
-                       zap.String("appID", appID),
-                       zap.String("taskID", taskID))
-               ev := NewSimpleTaskEvent(appID, taskID, CompleteTask)
-               dispatcher.Dispatch(ev)
-               if app.GetApplicationState() == ApplicationStates().Resuming {
-                       dispatcher.Dispatch(NewSimpleApplicationEvent(appID, 
AppTaskCompleted))
-               }
+       log.Log(log.ShimContext).Debug("release allocation",
+               zap.String("appID", app.applicationID),
+               zap.String("taskID", taskID))

Review Comment:
   Two times similar log we only need/want one



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to