Volcano——配置理解

Volcano配置

 1 apiVersion: v1
 2 kind: ConfigMap
 3 metadata:
 4   name: volcano-scheduler-configmap
 5   namespace: volcano-system
 6 data:
 7   volcano-scheduler.conf: |
 8     actions: "enqueue, allocate, backfill"
 9     tiers:
10     - plugins:
11       - name: priority
12       - name: gang
13       - name: conformance
14     - plugins:
15       - name: drf
16       - name: predicates
17       - name: proportion
18       - name: nodeorder
19       - name: binpack

 

actions

actions表示调度需要执行的动作。

Volcano每次调度会创建一个session,并按actions中配置的动作依次执行。

每个action里都设定好了执行逻辑,里面会调用session上的处理函数(xxxFn),这些函数都是由各个插件添加的。执行顺序参考tiers的配置。

 1 // runOnce executes a single scheduling cycle. This function is called periodically
 2 // as defined by the Scheduler's schedule period.
 3 func (pc *Scheduler) runOnce() {
 4     klog.V(4).Infof("Start scheduling ...")
 5     scheduleStartTime := time.Now()
 6     defer klog.V(4).Infof("End scheduling ...")
 7 
 8     pc.mutex.Lock()
 9     actions := pc.actions
10     plugins := pc.plugins
11     configurations := pc.configurations
12     pc.mutex.Unlock()
13 
14     // Load ConfigMap to check which action is enabled.
15     conf.EnabledActionMap = make(map[string]bool)
16     for _, action := range actions {
17         conf.EnabledActionMap[action.Name()] = true
18     }
19 
20     ssn := framework.OpenSession(pc.cache, plugins, configurations)
21     defer func() {
22         framework.CloseSession(ssn)
23         metrics.UpdateE2eDuration(metrics.Duration(scheduleStartTime))
24     }()
25 
26     for _, action := range actions {
27         actionStartTime := time.Now()
28         action.Execute(ssn)
29         metrics.UpdateActionDuration(action.Name(), metrics.Duration(actionStartTime))
30     }
31 }

 

tiers

上面配置中的tiers里有两个数组,在每个action里执行插件处理的时候,会按照tiers里定义的数组顺序以及组里插件顺序进行。

Volcano代码示例:

 1 func (ssn *Session) JobOrderFn(l, r interface{}) bool {
 2     for _, tier := range ssn.Tiers {
 3         for _, plugin := range tier.Plugins {
 4             if !isEnabled(plugin.EnabledJobOrder) {
 5                 continue
 6             }
 7             jof, found := ssn.jobOrderFns[plugin.Name]
 8             if !found {
 9                 continue
10             }
11             if j := jof(l, r); j != 0 {
12                 return j < 0
13             }
14         }
15     }
16 
17     // If no job order funcs, order job by CreationTimestamp first, then by UID.
18     lv := l.(*api.JobInfo)
19     rv := r.(*api.JobInfo)
20     if lv.CreationTimestamp.Equal(&rv.CreationTimestamp) {
21         return lv.UID < rv.UID
22     }
23     return lv.CreationTimestamp.Before(&rv.CreationTimestamp)
24 }

 

posted @ 2025-09-28 17:14  xiaoxiongfei  阅读(12)  评论(0)    收藏  举报