diff --git a/pkg/apis/v1alpha1/schedulingspec.go b/pkg/apis/v1alpha1/schedulingspec.go index 4a2941f451..2bc82f05e8 100644 --- a/pkg/apis/v1alpha1/schedulingspec.go +++ b/pkg/apis/v1alpha1/schedulingspec.go @@ -28,7 +28,7 @@ type SchedulingSpec struct { metav1.TypeMeta `json:",inline"` metav1.ObjectMeta `json:"metadata"` - Spec SchedulingSpecTemplate `json:"spec"` + Spec SchedulingSpecTemplate `json:"spec,omitempty" protobuf:"bytes,1,rep,name=spec"` } type SchedulingSpecTemplate struct { diff --git a/pkg/client/informers/factory.go b/pkg/client/informers/factory.go index 8c73f233e3..9607206a3f 100644 --- a/pkg/client/informers/factory.go +++ b/pkg/client/informers/factory.go @@ -110,15 +110,9 @@ type SharedInformerFactory interface { ForResource(resource schema.GroupVersionResource) (GenericInformer, error) WaitForCacheSync(stopCh <-chan struct{}) map[reflect.Type]bool - SchedulingSpec() arbclient.Interface - - QueueJob() arbclient.Interface -} - -func (f *sharedInformerFactory) SchedulingSpec() arbclient.Interface { - return arbclient.New(f) + Batch() arbclient.Interface } -func (f *sharedInformerFactory) QueueJob() arbclient.Interface { +func (f *sharedInformerFactory) Batch() arbclient.Interface { return arbclient.New(f) } diff --git a/pkg/client/informers/generic.go b/pkg/client/informers/generic.go index 22556345bc..38a241a8ee 100644 --- a/pkg/client/informers/generic.go +++ b/pkg/client/informers/generic.go @@ -52,16 +52,15 @@ func (f *genericInformer) Lister() cache.GenericLister { func (f *sharedInformerFactory) ForResource(resource schema.GroupVersionResource) (GenericInformer, error) { switch resource { // Group=, Version=V1 - case arbv1.SchemeGroupVersion.WithResource("schedulingspecs"): return &genericInformer{ resource: resource.GroupResource(), - informer: f.SchedulingSpec().SchedulingSpecs().Informer(), + informer: f.Batch().SchedulingSpecs().Informer(), }, nil case arbv1.SchemeGroupVersion.WithResource("queuejobs"): return &genericInformer{ resource: resource.GroupResource(), - informer: f.QueueJob().QueueJobs().Informer(), + informer: f.Batch().QueueJobs().Informer(), }, nil } diff --git a/pkg/controller/queuejob/queuejob_controller.go b/pkg/controller/queuejob/queuejob_controller.go index b31b709dff..196627e926 100644 --- a/pkg/controller/queuejob/queuejob_controller.go +++ b/pkg/controller/queuejob/queuejob_controller.go @@ -84,44 +84,22 @@ func NewQueueJobController(config *rest.Config) *Controller { panic(err) } - cc.queueJobInformer = arbinformers.NewSharedInformerFactory(queueJobClient, 0).QueueJob().QueueJobs() - cc.queueJobInformer.Informer().AddEventHandler( - cache.FilteringResourceEventHandler{ - FilterFunc: func(obj interface{}) bool { - switch t := obj.(type) { - case *arbv1.QueueJob: - glog.V(4).Infof("Filter QueueJob name(%s) namespace(%s)\n", t.Name, t.Namespace) - return true - default: - return false - } - }, - Handler: cache.ResourceEventHandlerFuncs{ - AddFunc: cc.addQueueJob, - UpdateFunc: cc.updateQueueJob, - DeleteFunc: cc.deleteQueueJob, - }, - }) + cc.queueJobInformer = arbinformers.NewSharedInformerFactory(queueJobClient, 0).Batch().QueueJobs() + cc.queueJobInformer.Informer().AddEventHandler(cache.ResourceEventHandlerFuncs{ + AddFunc: cc.addQueueJob, + UpdateFunc: cc.updateQueueJob, + DeleteFunc: cc.deleteQueueJob, + }) cc.queueJobLister = cc.queueJobInformer.Lister() cc.queueJobSynced = cc.queueJobInformer.Informer().HasSynced cc.podInformer = informers.NewSharedInformerFactory(cc.clients, 0).Core().V1().Pods() - cc.podInformer.Informer().AddEventHandler(cache.FilteringResourceEventHandler{ - FilterFunc: func(obj interface{}) bool { - switch t := obj.(type) { - case *v1.Pod: - glog.V(4).Infof("Filter Pod name(%s) namespace(%s)\n", t.Name, t.Namespace) - return true - default: - return false - } - }, - Handler: cache.ResourceEventHandlerFuncs{ - AddFunc: cc.addPod, - UpdateFunc: cc.updatePod, - DeleteFunc: cc.deletePod, - }, + cc.podInformer.Informer().AddEventHandler(cache.ResourceEventHandlerFuncs{ + AddFunc: cc.addPod, + UpdateFunc: cc.updatePod, + DeleteFunc: cc.deletePod, }) + cc.podListr = cc.podInformer.Lister() cc.podSynced = cc.podInformer.Informer().HasSynced diff --git a/pkg/scheduler/cache/cache.go b/pkg/scheduler/cache/cache.go index 9361cf7878..2a17ad89e6 100644 --- a/pkg/scheduler/cache/cache.go +++ b/pkg/scheduler/cache/cache.go @@ -33,7 +33,6 @@ import ( "k8s.io/client-go/rest" "k8s.io/client-go/tools/cache" - arbv1 "github.com/kubernetes-incubator/kube-arbitrator/pkg/apis/v1alpha1" "github.com/kubernetes-incubator/kube-arbitrator/pkg/client" informerfactory "github.com/kubernetes-incubator/kube-arbitrator/pkg/client/informers" arbclient "github.com/kubernetes-incubator/kube-arbitrator/pkg/client/informers/v1" @@ -183,14 +182,11 @@ func newSchedulerCache(config *rest.Config, schedulerName string) *SchedulerCach }) sc.pdbInformer = informerFactory.Policy().V1beta1().PodDisruptionBudgets() - sc.pdbInformer.Informer().AddEventHandler( - cache.FilteringResourceEventHandler{ - Handler: cache.ResourceEventHandlerFuncs{ - AddFunc: sc.AddPDB, - UpdateFunc: sc.UpdatePDB, - DeleteFunc: sc.DeletePDB, - }, - }) + sc.pdbInformer.Informer().AddEventHandler(cache.ResourceEventHandlerFuncs{ + AddFunc: sc.AddPDB, + UpdateFunc: sc.UpdatePDB, + DeleteFunc: sc.DeletePDB, + }) // create queue informer queueClient, _, err := client.NewClient(config) @@ -200,24 +196,12 @@ func newSchedulerCache(config *rest.Config, schedulerName string) *SchedulerCach schedulingSpecInformerFactory := informerfactory.NewSharedInformerFactory(queueClient, 0) // create informer for Queue information - sc.schedulingSpecInformer = schedulingSpecInformerFactory.SchedulingSpec().SchedulingSpecs() - sc.schedulingSpecInformer.Informer().AddEventHandler( - cache.FilteringResourceEventHandler{ - FilterFunc: func(obj interface{}) bool { - switch t := obj.(type) { - case *arbv1.SchedulingSpec: - glog.V(4).Infof("Filter Queue name(%s) namespace(%s)\n", t.Name, t.Namespace) - return true - default: - return false - } - }, - Handler: cache.ResourceEventHandlerFuncs{ - AddFunc: sc.AddSchedulingSpec, - UpdateFunc: sc.UpdateSchedulingSpec, - DeleteFunc: sc.DeleteSchedulingSpec, - }, - }) + sc.schedulingSpecInformer = schedulingSpecInformerFactory.Batch().SchedulingSpecs() + sc.schedulingSpecInformer.Informer().AddEventHandler(cache.ResourceEventHandlerFuncs{ + AddFunc: sc.AddSchedulingSpec, + UpdateFunc: sc.UpdateSchedulingSpec, + DeleteFunc: sc.DeleteSchedulingSpec, + }) return sc }