@@ -96,7 +96,6 @@ type SchedulerCache struct {
9696 nodeInformer infov1.NodeInformer
9797
9898 Binder Binder
99- Evictor Evictor
10099 StatusUpdater StatusUpdater
101100
102101 Recorder record.EventRecorder
@@ -106,8 +105,6 @@ type SchedulerCache struct {
106105
107106 taskCache * TaskCache
108107
109- NamespaceCollection map [string ]* schedulingapi.NamespaceCollection
110-
111108 errTasks workqueue.TypedRateLimitingInterface [string ]
112109 nodeQueue workqueue.TypedRateLimitingInterface [string ]
113110
@@ -361,16 +358,15 @@ func newSchedulerCache(config *rest.Config, schedulerNames []string, defaultQueu
361358 )
362359
363360 sc := & SchedulerCache {
364- Nodes : make (map [string ]* schedulingapi.NodeInfo ),
365- errTasks : workqueue.NewTypedRateLimitingQueue [string ](errTaskRateLimiter ),
366- nodeQueue : workqueue.NewTypedRateLimitingQueue [string ](workqueue .DefaultTypedControllerRateLimiter [string ]()),
367- kubeClient : kubeClient ,
368- vcClient : vcClient ,
369- restConfig : config ,
370- schedulerNames : schedulerNames ,
371- nodeSelectorLabels : make (map [string ]sets.Empty ),
372- NamespaceCollection : make (map [string ]* schedulingapi.NamespaceCollection ),
373- imageStates : make (map [string ]* imageState ),
361+ Nodes : make (map [string ]* schedulingapi.NodeInfo ),
362+ errTasks : workqueue.NewTypedRateLimitingQueue [string ](errTaskRateLimiter ),
363+ nodeQueue : workqueue.NewTypedRateLimitingQueue [string ](workqueue .DefaultTypedControllerRateLimiter [string ]()),
364+ kubeClient : kubeClient ,
365+ vcClient : vcClient ,
366+ restConfig : config ,
367+ schedulerNames : schedulerNames ,
368+ nodeSelectorLabels : make (map [string ]sets.Empty ),
369+ imageStates : make (map [string ]* imageState ),
374370
375371 NodeList : []string {},
376372 nodeWorkers : nodeWorkers ,
@@ -395,11 +391,6 @@ func newSchedulerCache(config *rest.Config, schedulerNames []string, defaultQueu
395391 }
396392 sc .Binder = GetBindMethod ()
397393
398- sc .Evictor = & defaultEvictor {
399- kubeclient : sc .kubeClient ,
400- recorder : sc .Recorder ,
401- }
402-
403394 sc .StatusUpdater = & defaultStatusUpdater {
404395 kubeclient : sc .kubeClient ,
405396 vcclient : sc .vcClient ,
@@ -572,9 +563,6 @@ func (sc *SchedulerCache) Run(stopCh <-chan struct{}) {
572563 // Re-sync error tasks.
573564 go wait .Until (sc .processResyncTask , 0 , stopCh )
574565
575- // Cleanup jobs.
576- go wait .Until (sc .processCleanupJob , 0 , stopCh )
577-
578566 go wait .Until (sc .processBindTask , time .Millisecond * 20 , stopCh )
579567
580568 sc .ConflictAwareBinder .Run (stopCh )
@@ -586,43 +574,6 @@ func (sc *SchedulerCache) WaitForCacheSync(stopCh <-chan struct{}) {
586574 sc .vcInformerFactory .WaitForCacheSync (stopCh )
587575}
588576
589- // Evict will evict the pod.
590- //
591- // If error occurs both task and job are guaranteed to be in the original state.
592- func (sc * SchedulerCache ) Evict (task * schedulingapi.TaskInfo , reason string ) error {
593- sc .Mutex .Lock ()
594- defer sc .Mutex .Unlock ()
595-
596- node , found := sc .Nodes [task .NodeName ]
597- if ! found {
598- return fmt .Errorf ("failed to evict Task %v from host %v, host does not exist" ,
599- task .UID , task .NodeName )
600- }
601-
602- originalStatus := task .Status
603-
604- // Add new task to node.
605- if err := node .UpdateTask (task ); err != nil {
606- // After failing to update task to a node we need to revert task status from Releasing,
607- // otherwise task might be stuck in the Releasing state indefinitely.
608- klog .Errorf ("Task <%s/%s> will be resynchronized after failing to revert status " +
609- "from %s to %s after failing to update Task on Node <%s>: %v" ,
610- task .Namespace , task .Name , task .Status , originalStatus , node .Name , err )
611- sc .resyncTask (task )
612- return err
613- }
614-
615- p := task .Pod
616-
617- go func () {
618- err := sc .Evictor .Evict (p , reason )
619- if err != nil {
620- sc .resyncTask (task )
621- }
622- }()
623- return nil
624- }
625-
626577// Bind binds task to the target host.
627578func (sc * SchedulerCache ) Bind (ctx context.Context , bindContexts []* vcache.BindContext , preBinders map [string ]PreBinder ) {
628579 readyToBindTasks := make ([]* schedulingapi.TaskInfo , len (bindContexts ))
@@ -747,10 +698,6 @@ func (sc *SchedulerCache) TaskUnschedulable(task *schedulingapi.TaskInfo, reason
747698 return nil
748699}
749700
750- func (sc * SchedulerCache ) processCleanupJob () {
751- // TODO process clean up Job
752- }
753-
754701// GetTaskInfo retrieves a task by its ID.
755702func (sc * SchedulerCache ) GetTaskInfo (taskID schedulingapi.TaskID ) (* schedulingapi.TaskInfo , bool ) {
756703 return sc .taskCache .Get (taskID )
@@ -772,15 +719,7 @@ func (sc *SchedulerCache) DeleteTaskInfo(taskID schedulingapi.TaskID) {
772719}
773720
774721func (sc * SchedulerCache ) resyncTask (task * schedulingapi.TaskInfo ) {
775- key := sc .generateErrTaskKey (task )
776- sc .errTasks .AddRateLimited (key )
777- }
778-
779- func (sc * SchedulerCache ) generateErrTaskKey (task * schedulingapi.TaskInfo ) string {
780- // Job UID is namespace + / +name, for example: theNs/theJob
781- // Task UID is derived from the Pod UID, for example: d336abea-4f14-42c7-8a6b-092959a31407
782- // In the example above, the key ultimately becomes: theNs/theJob/d336abea-4f14-42c7-8a6b-092959a31407
783- return fmt .Sprintf ("%s/%s" , task .Job , task .UID )
722+ sc .errTasks .AddRateLimited (string (task .UID ))
784723}
785724
786725func (sc * SchedulerCache ) parseErrTaskKey (key string ) (* schedulingapi.TaskInfo , error ) {
@@ -990,17 +929,15 @@ func (sc *SchedulerCache) BindTask() {
990929 sc .bindCache = make ([]* vcache.BindContext , 0 )
991930}
992931
993- // Snapshot returns the complete snapshot of the cluster from cache
932+ // Snapshot returns the complete snapshot of the cluster from cache, used for dump purpose only
994933func (sc * SchedulerCache ) Snapshot () * schedulingapi.ClusterInfo {
995934 sc .Mutex .Lock ()
996935 defer sc .Mutex .Unlock ()
997936
998937 snapshot := & schedulingapi.ClusterInfo {
999- Nodes : make (map [string ]* schedulingapi.NodeInfo ),
1000- RealNodesSet : make (map [string ]sets.Set [string ]),
1001- NamespaceInfo : make (map [schedulingapi.NamespaceName ]* schedulingapi.NamespaceInfo ),
1002- RevocableNodes : make (map [string ]* schedulingapi.NodeInfo ),
1003- NodeList : make ([]string , len (sc .NodeList )),
938+ Nodes : make (map [string ]* schedulingapi.NodeInfo ),
939+ RealNodesSet : make (map [string ]sets.Set [string ]),
940+ NodeList : make ([]string , len (sc .NodeList )),
1004941 }
1005942
1006943 // TODO add agent scheduler cache
@@ -1016,17 +953,8 @@ func (sc *SchedulerCache) Snapshot() *schedulingapi.ClusterInfo {
1016953 }
1017954
1018955 snapshot .Nodes [value .Name ] = value .Clone ()
1019-
1020- if value .RevocableZone != "" {
1021- snapshot .RevocableNodes [value .Name ] = snapshot .Nodes [value .Name ]
1022- }
1023956 }
1024-
1025- for _ , value := range sc .NamespaceCollection {
1026- info := value .Snapshot ()
1027- snapshot .NamespaceInfo [info .Name ] = info
1028- }
1029- klog .V (3 ).InfoS ("SnapShot for scheduling" , "NodeNum" , "NamespaceNum" , "RevocableNodesNum" , len (snapshot .Nodes ), len (snapshot .NamespaceInfo ), len (snapshot .RevocableNodes ))
957+ klog .V (3 ).InfoS ("SnapShot for scheduling" , "NodeNum" , len (snapshot .Nodes ))
1030958 return snapshot
1031959}
1032960
@@ -1060,14 +988,6 @@ func (sc *SchedulerCache) String() string {
1060988 }
1061989 }
1062990
1063- if len (sc .NamespaceCollection ) != 0 {
1064- str += "Namespaces:\n "
1065- for _ , ns := range sc .NamespaceCollection {
1066- info := ns .Snapshot ()
1067- str += fmt .Sprintf ("\t Namespace(%s)\n " , info .Name )
1068- }
1069- }
1070-
1071991 if len (sc .NodeList ) != 0 {
1072992 str += fmt .Sprintf ("NodeList: %v\n " , sc .NodeList )
1073993 }
0 commit comments