volcano.sh/volcano@v1.9.0/pkg/scheduler/cache/interface.go (about) 1 /* 2 Copyright 2017 The Kubernetes Authors. 3 4 Licensed under the Apache License, Version 2.0 (the "License"); 5 you may not use this file except in compliance with the License. 6 You may obtain a copy of the License at 7 8 http://www.apache.org/licenses/LICENSE-2.0 9 10 Unless required by applicable law or agreed to in writing, software 11 distributed under the License is distributed on an "AS IS" BASIS, 12 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 See the License for the specific language governing permissions and 14 limitations under the License. 15 */ 16 17 package cache 18 19 import ( 20 v1 "k8s.io/api/core/v1" 21 "k8s.io/client-go/informers" 22 "k8s.io/client-go/kubernetes" 23 "k8s.io/client-go/rest" 24 "k8s.io/client-go/tools/record" 25 26 "volcano.sh/volcano/pkg/scheduler/api" 27 "volcano.sh/volcano/pkg/scheduler/capabilities/volumebinding" 28 ) 29 30 // Cache collects pods/nodes/queues information 31 // and provides information snapshot 32 type Cache interface { 33 // Run start informer 34 Run(stopCh <-chan struct{}) 35 36 // Snapshot deep copy overall cache information into snapshot 37 Snapshot() *api.ClusterInfo 38 39 // WaitForCacheSync waits for all cache synced 40 WaitForCacheSync(stopCh <-chan struct{}) 41 42 // AddBindTask binds Task to the target host. 43 // TODO(jinzhej): clean up expire Tasks. 44 AddBindTask(task *api.TaskInfo) error 45 46 // BindPodGroup Pod/PodGroup to cluster 47 BindPodGroup(job *api.JobInfo, cluster string) error 48 49 // Evict evicts the task to release resources. 50 Evict(task *api.TaskInfo, reason string) error 51 52 // RecordJobStatusEvent records related events according to job status. 53 // Deprecated: remove it after removed PDB support. 54 RecordJobStatusEvent(job *api.JobInfo, updatePG bool) 55 56 // UpdateJobStatus puts job in backlog for a while. 57 UpdateJobStatus(job *api.JobInfo, updatePG bool) (*api.JobInfo, error) 58 59 // UpdateQueueStatus update queue status. 60 UpdateQueueStatus(queue *api.QueueInfo) error 61 62 // GetPodVolumes get pod volume on the host 63 GetPodVolumes(task *api.TaskInfo, node *v1.Node) (*volumebinding.PodVolumes, error) 64 65 // AllocateVolumes allocates volume on the host to the task 66 AllocateVolumes(task *api.TaskInfo, hostname string, podVolumes *volumebinding.PodVolumes) error 67 68 // BindVolumes binds volumes to the task 69 BindVolumes(task *api.TaskInfo, volumes *volumebinding.PodVolumes) error 70 71 // RevertVolumes clean cache generated by AllocateVolumes 72 RevertVolumes(task *api.TaskInfo, podVolumes *volumebinding.PodVolumes) 73 74 // Client returns the kubernetes clientSet, which can be used by plugins 75 Client() kubernetes.Interface 76 77 // ClientConfig returns the rest config 78 ClientConfig() *rest.Config 79 80 UpdateSchedulerNumaInfo(sets map[string]api.ResNumaSets) error 81 82 // SharedInformerFactory return scheduler SharedInformerFactory 83 SharedInformerFactory() informers.SharedInformerFactory 84 85 // SetMetricsConf set the metrics server related configuration 86 SetMetricsConf(conf map[string]string) 87 88 // EventRecorder returns the event recorder 89 EventRecorder() record.EventRecorder 90 } 91 92 // VolumeBinder interface for allocate and bind volumes 93 type VolumeBinder interface { 94 GetPodVolumes(task *api.TaskInfo, node *v1.Node) (*volumebinding.PodVolumes, error) 95 RevertVolumes(task *api.TaskInfo, podVolumes *volumebinding.PodVolumes) 96 AllocateVolumes(task *api.TaskInfo, hostname string, podVolumes *volumebinding.PodVolumes) error 97 BindVolumes(task *api.TaskInfo, podVolumes *volumebinding.PodVolumes) error 98 } 99 100 // Binder interface for binding task and hostname 101 type Binder interface { 102 Bind(kubeClient kubernetes.Interface, tasks []*api.TaskInfo) ([]*api.TaskInfo, error) 103 } 104 105 // Evictor interface for evict pods 106 type Evictor interface { 107 Evict(pod *v1.Pod, reason string) error 108 } 109 110 // StatusUpdater updates pod with given PodCondition 111 type StatusUpdater interface { 112 UpdatePodCondition(pod *v1.Pod, podCondition *v1.PodCondition) (*v1.Pod, error) 113 UpdatePodGroup(pg *api.PodGroup) (*api.PodGroup, error) 114 UpdateQueueStatus(queue *api.QueueInfo) error 115 } 116 117 // BatchBinder updates podgroup or job information 118 type BatchBinder interface { 119 Bind(job *api.JobInfo, cluster string) (*api.JobInfo, error) 120 }