Skip to content

Commit

Permalink
Add support for most requested priority
Browse files Browse the repository at this point in the history
Signed-off-by: Xiang Dai <long0dai@foxmail.com>
  • Loading branch information
daixiang0 committed May 24, 2020
1 parent f51e1f8 commit c641755
Showing 1 changed file with 36 additions and 24 deletions.
60 changes: 36 additions & 24 deletions pkg/scheduler/plugins/nodeorder/nodeorder.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,14 +42,16 @@ const (
LeastRequestedWeight = "leastrequested.weight"
// BalancedResourceWeight is the key for providing Balanced Resource Priority Weight in YAML
BalancedResourceWeight = "balancedresource.weight"
// MostRequestedWeight is the key for providing Most Requested Priority Weight in YAML
MostRequestedWeight = "mostrequested.weight"
)

type nodeOrderPlugin struct {
// Arguments given for the plugin
pluginArguments framework.Arguments
}

//New function returns prioritizePlugin object
// New function returns prioritize plugin object.
func New(aruguments framework.Arguments) framework.Plugin {
return &nodeOrderPlugin{pluginArguments: aruguments}
}
Expand All @@ -60,42 +62,52 @@ func (pp *nodeOrderPlugin) Name() string {

type priorityWeight struct {
leastReqWeight int
mostReqWeight int
nodeAffinityWeight int
podAffinityWeight int
balancedRescourceWeight int
}

// calculateWeight from the provided arguments.
//
// Currently only supported priorities are nodeaffinity, podaffinity, leastrequested,
// mostrequested, balancedresouce.
//
// User should specify priority weights in the config in this format:
//
// actions: "reclaim, allocate, backfill, preempt"
// tiers:
// - plugins:
// - name: priority
// - name: gang
// - name: conformance
// - plugins:
// - name: drf
// - name: predicates
// - name: proportion
// - name: nodeorder
// arguments:
// leastrequested.weight: 2
// mostrequested.weight: 0
// nodeaffinity.weight: 2
// podaffinity.weight: 2
// balancedresource.weight: 2
func calculateWeight(args framework.Arguments) priorityWeight {
/*
User Should give priorityWeight in this format(nodeaffinity.weight, podaffinity.weight, leastrequested.weight, balancedresource.weight).
Currently supported only for nodeaffinity, podaffinity, leastrequested, balancedresouce priorities.
actions: "reclaim, allocate, backfill, preempt"
tiers:
- plugins:
- name: priority
- name: gang
- name: conformance
- plugins:
- name: drf
- name: predicates
- name: proportion
- name: nodeorder
arguments:
nodeaffinity.weight: 2
podaffinity.weight: 2
leastrequested.weight: 2
balancedresource.weight: 2
*/

// Values are initialized to 1.

// Initial values for weights.
// By default, for backward compatibility and for reasonable scores,
// least requested priority is enabled and most requested priority is disabled.
weight := priorityWeight{
leastReqWeight: 1,
mostReqWeight: 0,
nodeAffinityWeight: 1,
podAffinityWeight: 1,
balancedRescourceWeight: 1,
}

// Checks whether mostrequested.weight is provided or not, if given, modifies the value in weight struct.
args.GetInt(&weight.mostReqWeight, MostRequestedWeight)

// Checks whether nodeaffinity.weight is provided or not, if given, modifies the value in weight struct.
args.GetInt(&weight.nodeAffinityWeight, NodeAffinityWeight)

Expand Down

0 comments on commit c641755

Please sign in to comment.