volcano-sh / volcano

A Cloud Native Batch System (Project under CNCF)
https://volcano.sh
Apache License 2.0
3.92k stars 903 forks source link

❇️ add vcinformer.SharedInformerFactory, vcClient vcclient.Interface to framework.Session #3554

Open kingeasternsun opened 1 week ago

kingeasternsun commented 1 week ago

What would you like to be added:

add

vcinformer.SharedInformerFactory
vcClient     vcclient.Interface 

to framework.Sesstion

type Session struct {
    UID types.UID

    kubeClient      kubernetes.Interface
    recorder        record.EventRecorder
    cache           cache.Cache
    restConfig      *rest.Config
    informerFactory informers.SharedInformerFactory

    vcinformer.SharedInformerFactory
    vcClient     vcclient.Interface 

Why is this needed:

Some plugin need get vcClient and vcinformer from session, otherwise they have to create a separate vcClient and vcinformer.

for example, in ascend-volcano-plugin https://gitee.com/ascend/ascend-for-volcano/blob/branch_v6.0.0-RC1/plugin/factory.go#L426 , they have to create a a separate vcClient and vcinformer, these vcinfomer cannot share indexer cache with the informer in scheduler.


func (sHandle *ScheduleHandler) initNSLB2(ssn *framework.Session) error {
    vcClient, err := NewVCClinetk8s()
    if err != nil {
        klog.V(util.LogErrorLev).Infof("create vc client err: %v.", err)
        return err
    }
    factory := externalversions.NewSharedInformerFactory(vcClient, 0)
    pgInformer := factory.Scheduling().V1beta1().PodGroups()
    cacheIndexer := pgInformer.Informer().GetIndexer()
    agents, err := NewAgent(ssn.KubeClient(), newConfig())
    if err != nil {
        klog.V(util.LogErrorLev).Infof("create agent err: %v", err)
        return err
    }
    ...
}
Monokaix commented 1 week ago

I think it's reasonable.

lowang-bh commented 2 days ago

Why informer is used instead of snapshot of that?