pbacsko commented on code in PR #598:
URL: https://github.com/apache/yunikorn-k8shim/pull/598#discussion_r1203963016


##########
pkg/appmgmt/appmgmt_recovery.go:
##########
@@ -63,14 +64,18 @@ func (svc *AppManagementService) recoverApps() 
(map[string]interfaces.ManagedApp
                                return pods[i].CreationTimestamp.Unix() < 
pods[j].CreationTimestamp.Unix()
                        })
 
+                       // Track pods that we have already seen in order to
+                       // skip redundant handling of async events in 
RecoveryDone
+                       seenEvents := make(map[types.UID]string)
                        for _, pod := range pods {
                                if utils.NeedRecovery(pod) {

Review Comment:
   I suggest something else which might be better. Instead of saving the pods 
which are still running and relying on versions, we might be better off saving 
the terminated pods. So we can do this:
   ```
   var terminatedPods map[string]bool
   ...
   for _, pod := range pods {
     if isYunikornPod(pod) {
       if isRunningPod(pod) {
         app := svc.podEventHandler.HandleEvent(general.AddPod, 
general.Recovery, pod)
         recoveringApps[app.GetApplicationID()] = app
         continue
      }
      terminatedPods[string(pod.UID)] = true
     }
   }
   ...
   svc.podEventHandler.RecoveryDone(terminatedPods)
   ```
   
   So we don't care about the version. If a pod is finished in when we're in 
the process of listing, it's done, we no longer care about it. It won't come 
back to a non-finished state again.
   
   ```
   for _, event := range p.asyncEvents {
    uid := string(event.pod.UID)
    if terminatedPods[uid] {
       continue
    }
    p.internalHandle(event.eventType, Informers, event.pod)
   }
   ```
   
   I strongly believe that this is more easier to understand. Saving & checking 
versions just adds more complications.



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