chia7712 commented on code in PR #844:
URL: https://github.com/apache/yunikorn-k8shim/pull/844#discussion_r1607143753


##########
pkg/client/clients.go:
##########
@@ -67,38 +68,40 @@ func (c *Clients) GetConf() *conf.SchedulerConf {
        return c.conf
 }
 
+func (c *Clients) getInformers() []cache.SharedIndexInformer {
+       return []cache.SharedIndexInformer{
+               c.PodInformer.Informer(),
+               c.NodeInformer.Informer(),
+               c.ConfigMapInformer.Informer(),
+               c.PVInformer.Informer(),
+               c.PVCInformer.Informer(),
+               c.StorageInformer.Informer(),
+               c.CSINodeInformer.Informer(),
+               c.NamespaceInformer.Informer(),
+               c.PriorityClassInformer.Informer(),
+       }
+}
+
 func (c *Clients) WaitForSync() {
        syncStartTime := time.Now()
        counter := 0
-       for {
-               if c.NodeInformer.Informer().HasSynced() &&
-                       c.PodInformer.Informer().HasSynced() &&
-                       c.PVCInformer.Informer().HasSynced() &&
-                       c.PVInformer.Informer().HasSynced() &&
-                       c.StorageInformer.Informer().HasSynced() &&
-                       c.CSINodeInformer.Informer().HasSynced() &&
-                       c.ConfigMapInformer.Informer().HasSynced() &&
-                       c.NamespaceInformer.Informer().HasSynced() &&
-                       c.PriorityClassInformer.Informer().HasSynced() {
-                       return
-               }
-               time.Sleep(time.Second)
-               counter++
-               if counter%10 == 0 {
-                       log.Log(log.ShimClient).Info("Waiting for informers to 
sync",
-                               zap.Duration("timeElapsed", 
time.Since(syncStartTime).Round(time.Second)))
+
+LOOP:

Review Comment:
   All we want to do is to make sure all get synced, right? Hence, we can check 
informer one by one.
   ```go
        for _, informer := range c.getInformers() {
                for !informer.HasSynced() {
                        time.Sleep(time.Second)
                        counter++
                        if counter%10 == 0 {
                                log.Log(log.ShimClient).Info("Waiting for 
informers to sync",
                                        zap.Duration("timeElapsed", 
time.Since(syncStartTime).Round(time.Second)))
                        }
                }
        }
   ```
   
   Also, that will create a slice only once.



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