You are viewing a plain text version of this content. The canonical link for it is here.
Posted to reviews@yunikorn.apache.org by GitBox <gi...@apache.org> on 2020/12/22 07:46:15 UTC

[GitHub] [incubator-yunikorn-k8shim] HuangTing-Yao commented on a change in pull request #213: [YUNIKORN-478]Handle app completion at the shim side

HuangTing-Yao commented on a change in pull request #213:
URL: https://github.com/apache/incubator-yunikorn-k8shim/pull/213#discussion_r547119304



##########
File path: pkg/callback/scheduler_callback.go
##########
@@ -118,15 +118,36 @@ func (callback *AsyncRMCallback) RecvUpdateResponse(response *si.UpdateResponse)
 	for _, release := range response.ReleasedAllocations {
 		log.Logger().Debug("callback: response to released allocations",
 			zap.String("UUID", release.UUID))
+
+		// delete the allocated pod
+		if app := callback.context.GetApplicationInternal(release.ApplicationID); app != nil {
+			// TerminationType 0 mean STOPPED_BY_RM
+			if release.TerminationType != si.AllocationRelease_STOPPED_BY_RM {
+				for _, task := range app.GetTaskMap() {
+					if task.GetTaskAllocationUUID() == release.UUID {
+						err := task.DeleteTaskPod(task.GetTaskPod())
+						if err != nil {
+							log.Logger().Error("failed to delete pod", zap.Error(err))
+						}
+					}
+				}
+			}
+		}
 	}
 
 	// handle status changes
 	for _, updated := range response.UpdatedApplications {
 		log.Logger().Debug("status update callback received",
 			zap.String("appId", updated.ApplicationID),
 			zap.String("new status", updated.State))
-
-		//handle status update
+		// delete application from context
+		if updated.State == events.States().Application.Completed {
+			err := callback.context.RemoveApplicationInternal(updated.ApplicationID)
+			if err != nil {
+				log.Logger().Error("failed to delete application", zap.Error(err))
+			}
+		}
+		// handle status update
 		dispatcher.Dispatch(cache.NewApplicationStatusChangeEvent(updated.ApplicationID, events.AppStateChange, updated.State))

Review comment:
       OK, done.

##########
File path: pkg/callback/scheduler_callback.go
##########
@@ -118,15 +118,36 @@ func (callback *AsyncRMCallback) RecvUpdateResponse(response *si.UpdateResponse)
 	for _, release := range response.ReleasedAllocations {
 		log.Logger().Debug("callback: response to released allocations",
 			zap.String("UUID", release.UUID))
+
+		// delete the allocated pod
+		if app := callback.context.GetApplicationInternal(release.ApplicationID); app != nil {
+			// TerminationType 0 mean STOPPED_BY_RM
+			if release.TerminationType != si.AllocationRelease_STOPPED_BY_RM {
+				for _, task := range app.GetTaskMap() {
+					if task.GetTaskAllocationUUID() == release.UUID {
+						err := task.DeleteTaskPod(task.GetTaskPod())
+						if err != nil {
+							log.Logger().Error("failed to delete pod", zap.Error(err))
+						}
+					}
+				}
+			}
+		}

Review comment:
       OK, done.




----------------------------------------------------------------
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.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org