[ 
https://issues.apache.org/jira/browse/YUNIKORN-2625?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17847928#comment-17847928
 ] 

Chia-Ping Tsai commented on YUNIKORN-2625:
------------------------------------------

The change we need is a new method used to return all informers. That should be 
a small helper which can avoid listing all informers in each method manually. 
Also, that can simplify the test of clients since we don’t need to define each 
informer. Instead, we can override the helper to return the mock one.

> Refactor Clients to avoid hard-code checks
> ------------------------------------------
>
>                 Key: YUNIKORN-2625
>                 URL: https://issues.apache.org/jira/browse/YUNIKORN-2625
>             Project: Apache YuniKorn
>          Issue Type: Improvement
>            Reporter: Chia-Ping Tsai
>            Assignee: Arthur Wang
>            Priority: Minor
>              Labels: pull-request-available
>
>  
> {code:java}
> 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
> } {code}
>  
> {code:java}
> go c.NodeInformer.Informer().Run(stopCh)
> go c.PodInformer.Informer().Run(stopCh)
> go c.PVInformer.Informer().Run(stopCh)
> go c.PVCInformer.Informer().Run(stopCh)
> go c.StorageInformer.Informer().Run(stopCh)
> go c.CSINodeInformer.Informer().Run(stopCh)
> go c.ConfigMapInformer.Informer().Run(stopCh)
> go c.NamespaceInformer.Informer().Run(stopCh)
> go c.PriorityClassInformer.Informer().Run(stopCh) {code}
> Instead of listing all informer manually, we should add a method to `Clients` 
> to list all informers and then loop all of them. That can bring two benefits.
>  
>  # more readable
>  # easy to write tests. We can override the `informers` method to return mock 
> informer
>  # avoid error-prone (we could miss one of informers in adding more helper 
> methods in the future)
>  
>  



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to