❇️ add vcinformer.SharedInformerFactory, vcClient vcclient.Interface to framework.Session
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
}
...
}
I think it's reasonable.
Why informer is used instead of snapshot of that?
Does this feature need to be added? I have proposed a PR.
Why informer is used instead of snapshot of that?
+1, IMO, I also think it is more reasonable to use snapshot.
But I am not sure about the purpose of these two variables introduced by this plugin. I think if we need to obtain resource objects from k8s, we should use snapshot instead of introducing informerFactory again, because snapshot is originally a cache obtained by informerFactory. Excessive introduction of other variables is not a good design method, especially the informerFactory cache, which may also increase memory usage.
I think the key problem is the purpose of the plugin using the informer, if it's a generic scenario, it can be provided in the session, if the plugin has additional processing logic, it can be placed in the snapshot, but this will also increase the cache.
I think the key problem is the purpose of the plugin using the informer, if it's a generic scenario, it can be provided in the session, if the plugin has additional processing logic, it can be placed in the snapshot, but this will also increase the cache.
yep, so far I know that the ascend-volcano-plugin https://gitee.com/ascend/ascend-for-volcano/blob/branch_v6.0.0-RC1/plugin/factory.go#L426 has this requeirement. But many complex plugin I known, they need keep their own cache by informer eventhandler, so they need a infomer factory. If volcano not give this , each plugin have to construct a individual shared informer factory, could not share informer cache with each other. @Monokaix @googs1025 @lowang-bh