volcano.sh/volcano@v1.9.0/pkg/scheduler/plugins/conformance/conformance.go (about) 1 /* 2 Copyright 2018 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 conformance 18 19 import ( 20 v1 "k8s.io/apimachinery/pkg/apis/meta/v1" 21 "k8s.io/kubernetes/pkg/apis/scheduling" 22 23 "volcano.sh/volcano/pkg/scheduler/api" 24 "volcano.sh/volcano/pkg/scheduler/framework" 25 "volcano.sh/volcano/pkg/scheduler/plugins/util" 26 ) 27 28 // PluginName indicates name of volcano scheduler plugin. 29 const PluginName = "conformance" 30 31 type conformancePlugin struct { 32 // Arguments given for the plugin 33 pluginArguments framework.Arguments 34 } 35 36 // New return conformance plugin 37 func New(arguments framework.Arguments) framework.Plugin { 38 return &conformancePlugin{pluginArguments: arguments} 39 } 40 41 func (pp *conformancePlugin) Name() string { 42 return PluginName 43 } 44 45 func (pp *conformancePlugin) OnSessionOpen(ssn *framework.Session) { 46 evictableFn := func(evictor *api.TaskInfo, evictees []*api.TaskInfo) ([]*api.TaskInfo, int) { 47 var victims []*api.TaskInfo 48 49 for _, evictee := range evictees { 50 className := evictee.Pod.Spec.PriorityClassName 51 // Skip critical pod. 52 if className == scheduling.SystemClusterCritical || 53 className == scheduling.SystemNodeCritical || 54 evictee.Namespace == v1.NamespaceSystem { 55 continue 56 } 57 58 victims = append(victims, evictee) 59 } 60 61 return victims, util.Permit 62 } 63 64 ssn.AddPreemptableFn(pp.Name(), evictableFn) 65 ssn.AddReclaimableFn(pp.Name(), evictableFn) 66 } 67 68 func (pp *conformancePlugin) OnSessionClose(ssn *framework.Session) {}