volcano.sh/volcano@v1.9.0/pkg/scheduler/plugins/util/k8s/framework.go (about) 1 /* 2 Copyright 2020 The Volcano 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 k8s 18 19 import ( 20 "context" 21 22 v1 "k8s.io/api/core/v1" 23 "k8s.io/apimachinery/pkg/types" 24 "k8s.io/client-go/informers" 25 "k8s.io/client-go/kubernetes" 26 "k8s.io/client-go/rest" 27 "k8s.io/client-go/tools/events" 28 "k8s.io/klog/v2" 29 "k8s.io/kubernetes/pkg/scheduler/apis/config" 30 "k8s.io/kubernetes/pkg/scheduler/framework" 31 "k8s.io/kubernetes/pkg/scheduler/framework/parallelize" 32 33 scheduling "volcano.sh/volcano/pkg/scheduler/capabilities/volumebinding" 34 ) 35 36 // Framework is a K8S framework who mainly provides some methods 37 // about snapshot and plugins such as predicates 38 type Framework struct { 39 snapshot framework.SharedLister 40 kubeClient kubernetes.Interface 41 informerFactory informers.SharedInformerFactory 42 } 43 44 var _ framework.Handle = &Framework{} 45 46 // SnapshotSharedLister returns the scheduler's SharedLister of the latest NodeInfo 47 // snapshot. The snapshot is taken at the beginning of a scheduling cycle and remains 48 // unchanged until a pod finishes "Reserve". There is no guarantee that the information 49 // remains unchanged after "Reserve". 50 func (f *Framework) SnapshotSharedLister() framework.SharedLister { 51 return f.snapshot 52 } 53 54 // IterateOverWaitingPods acquires a read lock and iterates over the WaitingPods map. 55 func (f *Framework) IterateOverWaitingPods(callback func(framework.WaitingPod)) { 56 panic("not implemented") 57 } 58 59 // GetWaitingPod returns a reference to a WaitingPod given its UID. 60 func (f *Framework) GetWaitingPod(uid types.UID) framework.WaitingPod { 61 panic("not implemented") 62 } 63 64 // HasFilterPlugins returns true if at least one filter plugin is defined. 65 func (f *Framework) HasFilterPlugins() bool { 66 panic("not implemented") 67 } 68 69 // HasScorePlugins returns true if at least one score plugin is defined. 70 func (f *Framework) HasScorePlugins() bool { 71 panic("not implemented") 72 } 73 74 // ListPlugins returns a map of extension point name to plugin names configured at each extension 75 // point. Returns nil if no plugins where configred. 76 func (f *Framework) ListPlugins() map[string][]config.Plugin { 77 panic("not implemented") 78 } 79 80 // ClientSet returns a kubernetes clientset. 81 func (f *Framework) ClientSet() kubernetes.Interface { 82 return f.kubeClient 83 } 84 85 // SharedInformerFactory returns a shared informer factory. 86 func (f *Framework) SharedInformerFactory() informers.SharedInformerFactory { 87 return f.informerFactory 88 } 89 90 // VolumeBinder returns the volume binder used by scheduler. 91 func (f *Framework) VolumeBinder() scheduling.SchedulerVolumeBinder { 92 panic("not implemented") 93 } 94 95 // EventRecorder was introduced in k8s v1.19.6 and to be implemented 96 func (f *Framework) EventRecorder() events.EventRecorder { 97 return nil 98 } 99 100 func (f *Framework) AddNominatedPod(logger klog.Logger, pod *framework.PodInfo, nominatingInfo *framework.NominatingInfo) { 101 panic("implement me") 102 } 103 104 func (f *Framework) DeleteNominatedPodIfExists(pod *v1.Pod) { 105 panic("implement me") 106 } 107 108 func (f *Framework) UpdateNominatedPod(logger klog.Logger, oldPod *v1.Pod, newPodInfo *framework.PodInfo) { 109 panic("implement me") 110 } 111 112 func (f *Framework) NominatedPodsForNode(nodeName string) []*framework.PodInfo { 113 panic("implement me") 114 } 115 116 func (f *Framework) RunPreScorePlugins(ctx context.Context, state *framework.CycleState, pod *v1.Pod, nodes []*v1.Node) *framework.Status { 117 panic("implement me") 118 } 119 120 func (f *Framework) RunScorePlugins(ctx context.Context, state *framework.CycleState, pod *v1.Pod, nodes []*v1.Node) ([]framework.NodePluginScores, *framework.Status) { 121 panic("implement me") 122 } 123 124 func (f *Framework) RunFilterPlugins(ctx context.Context, state *framework.CycleState, pod *v1.Pod, info *framework.NodeInfo) *framework.Status { 125 panic("implement me") 126 } 127 128 func (f *Framework) RunPreFilterExtensionAddPod(ctx context.Context, state *framework.CycleState, podToSchedule *v1.Pod, podInfoToAdd *framework.PodInfo, nodeInfo *framework.NodeInfo) *framework.Status { 129 panic("implement me") 130 } 131 132 func (f *Framework) RunPreFilterExtensionRemovePod(ctx context.Context, state *framework.CycleState, podToSchedule *v1.Pod, podInfoToRemove *framework.PodInfo, nodeInfo *framework.NodeInfo) *framework.Status { 133 panic("implement me") 134 } 135 136 func (f *Framework) RejectWaitingPod(uid types.UID) bool { 137 panic("implement me") 138 } 139 140 func (f *Framework) KubeConfig() *rest.Config { 141 panic("implement me") 142 } 143 144 func (f *Framework) RunFilterPluginsWithNominatedPods(ctx context.Context, state *framework.CycleState, pod *v1.Pod, info *framework.NodeInfo) *framework.Status { 145 panic("implement me") 146 } 147 148 func (f *Framework) Extenders() []framework.Extender { 149 panic("implement me") 150 } 151 152 func (f *Framework) Parallelizer() parallelize.Parallelizer { 153 return parallelize.NewParallelizer(16) 154 } 155 156 // NewFrameworkHandle creates a FrameworkHandle interface, which is used by k8s plugins. 157 func NewFrameworkHandle(nodeMap map[string]*framework.NodeInfo, client kubernetes.Interface, informerFactory informers.SharedInformerFactory) framework.Handle { 158 snapshot := NewSnapshot(nodeMap) 159 return &Framework{ 160 snapshot: snapshot, 161 kubeClient: client, 162 informerFactory: informerFactory, 163 } 164 }