Skip to content
This repository was archived by the owner on May 25, 2023. It is now read-only.

Commit 66162c4

Browse files
authored
Merge pull request #628 from k82cn/automated-cherry-pick-of-#625-upstream-release-0.4
Automated cherry pick of #625: Change Plugin name prioritize to nodeOrder
2 parents d99f8c1 + ddc8cea commit 66162c4

File tree

12 files changed

+28
-28
lines changed

12 files changed

+28
-28
lines changed

config/kube-batch-conf.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,4 @@ tiers:
88
- name: drf
99
- name: predicates
1010
- name: proportion
11-
- name: prioritize
11+
- name: nodeorder

example/kube-batch-conf.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,4 @@ tiers:
88
- name: drf
99
- name: predicates
1010
- name: proportion
11-
- name: prioritize
11+
- name: nodeorder

pkg/scheduler/actions/allocate/allocate.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ func (alloc *allocateAction) Execute(ssn *framework.Session) {
132132
}
133133
}
134134
for _, node := range predicateNodes {
135-
score, err := ssn.PriorityFn(task, node)
135+
score, err := ssn.NodeOrderFn(task, node)
136136
if err != nil {
137137
glog.V(3).Infof("Error in Calculating Priority for the node:%v", err)
138138
} else {

pkg/scheduler/actions/preempt/preempt.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -188,7 +188,7 @@ func preempt(
188188
}
189189
}
190190
for _, node := range predicateNodes {
191-
score, err := ssn.PriorityFn(preemptor, node)
191+
score, err := ssn.NodeOrderFn(preemptor, node)
192192
if err != nil {
193193
glog.V(3).Infof("Error in Calculating Priority for the node:%v", err)
194194
} else {

pkg/scheduler/api/types.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -103,5 +103,5 @@ type PredicateFn func(*TaskInfo, *NodeInfo) error
103103
// EvictableFn is the func declaration used to evict tasks.
104104
type EvictableFn func(*TaskInfo, []*TaskInfo) []*TaskInfo
105105

106-
// PriorityFn is the func declaration used to get priority score for a node for a particular task.
107-
type PriorityFn func(*TaskInfo, *NodeInfo) (int, error)
106+
// NodeOrderFn is the func declaration used to get priority score for a node for a particular task.
107+
type NodeOrderFn func(*TaskInfo, *NodeInfo) (int, error)

pkg/scheduler/conf/scheduler_conf.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,6 @@ type PluginOption struct {
4747
QueueOrderDisabled bool `yaml:"disableQueueOrder"`
4848
// PredicateDisabled defines whether predicateFn is disabled
4949
PredicateDisabled bool `yaml:"disablePredicate"`
50-
// PriortizeDisabled defines whether PriorityFn is disabled
51-
PriortizeDisabled bool `yaml:"disablePrioritize"`
50+
// NodeOrderDisabled defines whether NodeOrderFn is disabled
51+
NodeOrderDisabled bool `yaml:"disableNodeOrder"`
5252
}

pkg/scheduler/framework/session.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ type Session struct {
4949
queueOrderFns map[string]api.CompareFn
5050
taskOrderFns map[string]api.CompareFn
5151
predicateFns map[string]api.PredicateFn
52-
priorityFns map[string]api.PriorityFn
52+
nodeOrderFns map[string]api.NodeOrderFn
5353
preemptableFns map[string]api.EvictableFn
5454
reclaimableFns map[string]api.EvictableFn
5555
overusedFns map[string]api.ValidateFn
@@ -71,7 +71,7 @@ func openSession(cache cache.Cache) *Session {
7171
queueOrderFns: map[string]api.CompareFn{},
7272
taskOrderFns: map[string]api.CompareFn{},
7373
predicateFns: map[string]api.PredicateFn{},
74-
priorityFns: map[string]api.PriorityFn{},
74+
nodeOrderFns: map[string]api.NodeOrderFn{},
7575
preemptableFns: map[string]api.EvictableFn{},
7676
reclaimableFns: map[string]api.EvictableFn{},
7777
overusedFns: map[string]api.ValidateFn{},

pkg/scheduler/framework/session_plugins.go

+5-5
Original file line numberDiff line numberDiff line change
@@ -48,8 +48,8 @@ func (ssn *Session) AddPredicateFn(name string, pf api.PredicateFn) {
4848
ssn.predicateFns[name] = pf
4949
}
5050

51-
func (ssn *Session) AddPriorityFn(name string, pf api.PriorityFn) {
52-
ssn.priorityFns[name] = pf
51+
func (ssn *Session) AddNodeOrderFn(name string, pf api.NodeOrderFn) {
52+
ssn.nodeOrderFns[name] = pf
5353
}
5454

5555
func (ssn *Session) AddOverusedFn(name string, fn api.ValidateFn) {
@@ -298,14 +298,14 @@ func (ssn *Session) PredicateFn(task *api.TaskInfo, node *api.NodeInfo) error {
298298
return nil
299299
}
300300

301-
func (ssn *Session) PriorityFn(task *api.TaskInfo, node *api.NodeInfo) (int, error) {
301+
func (ssn *Session) NodeOrderFn(task *api.TaskInfo, node *api.NodeInfo) (int, error) {
302302
priorityScore := 0
303303
for _, tier := range ssn.Tiers {
304304
for _, plugin := range tier.Plugins {
305-
if plugin.PriortizeDisabled {
305+
if plugin.NodeOrderDisabled {
306306
continue
307307
}
308-
pfn, found := ssn.priorityFns[plugin.Name]
308+
pfn, found := ssn.nodeOrderFns[plugin.Name]
309309
if !found {
310310
continue
311311
}

pkg/scheduler/plugins/factory.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,8 @@ import (
2222
"github.com/kubernetes-sigs/kube-batch/pkg/scheduler/plugins/conformance"
2323
"github.com/kubernetes-sigs/kube-batch/pkg/scheduler/plugins/drf"
2424
"github.com/kubernetes-sigs/kube-batch/pkg/scheduler/plugins/gang"
25+
"github.com/kubernetes-sigs/kube-batch/pkg/scheduler/plugins/nodeorder"
2526
"github.com/kubernetes-sigs/kube-batch/pkg/scheduler/plugins/predicates"
26-
"github.com/kubernetes-sigs/kube-batch/pkg/scheduler/plugins/prioritize"
2727
"github.com/kubernetes-sigs/kube-batch/pkg/scheduler/plugins/priority"
2828
"github.com/kubernetes-sigs/kube-batch/pkg/scheduler/plugins/proportion"
2929
)
@@ -34,7 +34,7 @@ func init() {
3434
framework.RegisterPluginBuilder("gang", gang.New)
3535
framework.RegisterPluginBuilder("predicates", predicates.New)
3636
framework.RegisterPluginBuilder("priority", priority.New)
37-
framework.RegisterPluginBuilder("prioritize", prioritize.New)
37+
framework.RegisterPluginBuilder("nodeorder", nodeorder.New)
3838
framework.RegisterPluginBuilder("conformance", conformance.New)
3939

4040
// Plugins for Queues

pkg/scheduler/plugins/prioritize/prioritize.go renamed to pkg/scheduler/plugins/nodeorder/nodeorder.go

+9-9
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ See the License for the specific language governing permissions and
1414
limitations under the License.
1515
*/
1616

17-
package prioritize
17+
package nodeorder
1818

1919
import (
2020
"fmt"
@@ -32,7 +32,7 @@ import (
3232
"github.com/kubernetes-sigs/kube-batch/pkg/scheduler/framework"
3333
)
3434

35-
type prioritizePlugin struct {
35+
type nodeOrderPlugin struct {
3636
}
3737

3838
func getInterPodAffinityScore(name string, interPodAffinityScore schedulerapi.HostPriorityList) int {
@@ -146,15 +146,15 @@ func (nl *nodeLister) List() ([]*v1.Node, error) {
146146

147147
//New function returns prioritizePlugin object
148148
func New() framework.Plugin {
149-
return &prioritizePlugin{}
149+
return &nodeOrderPlugin{}
150150
}
151151

152-
func (pp *prioritizePlugin) Name() string {
153-
return "prioritize"
152+
func (pp *nodeOrderPlugin) Name() string {
153+
return "nodeorder"
154154
}
155155

156-
func (pp *prioritizePlugin) OnSessionOpen(ssn *framework.Session) {
157-
priorityFn := func(task *api.TaskInfo, node *api.NodeInfo) (int, error) {
156+
func (pp *nodeOrderPlugin) OnSessionOpen(ssn *framework.Session) {
157+
nodeOrderFn := func(task *api.TaskInfo, node *api.NodeInfo) (int, error) {
158158

159159
pl := &podLister{
160160
session: ssn,
@@ -207,8 +207,8 @@ func (pp *prioritizePlugin) OnSessionOpen(ssn *framework.Session) {
207207
glog.V(4).Infof("Total Score for that node is: %d", score)
208208
return score, nil
209209
}
210-
ssn.AddPriorityFn(pp.Name(), priorityFn)
210+
ssn.AddNodeOrderFn(pp.Name(), nodeOrderFn)
211211
}
212212

213-
func (pp *prioritizePlugin) OnSessionClose(ssn *framework.Session) {
213+
func (pp *nodeOrderPlugin) OnSessionClose(ssn *framework.Session) {
214214
}

pkg/scheduler/util.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ tiers:
3737
- name: drf
3838
- name: predicates
3939
- name: proportion
40-
- name: prioritize
40+
- name: nodeorder
4141
`
4242

4343
func loadSchedulerConf(confStr string) ([]framework.Action, []conf.Tier, error) {

test/e2e/prioritize.go renamed to test/e2e/nodeorder.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ import (
2525
kubeletapi "k8s.io/kubernetes/pkg/kubelet/apis"
2626
)
2727

28-
var _ = Describe("Prioritize E2E Test", func() {
28+
var _ = Describe("NodeOrder E2E Test", func() {
2929
It("Node Affinity Test", func() {
3030
context := initTestContext()
3131
defer cleanupTestContext(context)

0 commit comments

Comments
 (0)