Skip to content

Commit

Permalink
Merge pull request #3551 from PigNatovsky/refactor/set-init-bool
Browse files Browse the repository at this point in the history
Remove init variable in Reclaimable and Preemptable parts of session_plugins
  • Loading branch information
volcano-sh-bot authored Oct 10, 2024
2 parents 20a6114 + 7976b63 commit 21bb2da
Showing 1 changed file with 4 additions and 7 deletions.
11 changes: 4 additions & 7 deletions pkg/scheduler/framework/session_plugins.go
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,6 @@ func (ssn *Session) AddJobStarvingFns(name string, fn api.ValidateFn) {
// Reclaimable invoke reclaimable function of the plugins
func (ssn *Session) Reclaimable(reclaimer *api.TaskInfo, reclaimees []*api.TaskInfo) []*api.TaskInfo {
var victims []*api.TaskInfo
var init bool

for _, tier := range ssn.Tiers {
for _, plugin := range tier.Plugins {
Expand All @@ -173,9 +172,9 @@ func (ssn *Session) Reclaimable(reclaimer *api.TaskInfo, reclaimees []*api.TaskI
victims = nil
break
}
if !init {
// first iteration - initialize victims list
if victims == nil {
victims = candidates
init = true
} else {
var intersection []*api.TaskInfo
// Get intersection of victims and candidates.
Expand Down Expand Up @@ -203,7 +202,6 @@ func (ssn *Session) Reclaimable(reclaimer *api.TaskInfo, reclaimees []*api.TaskI
// Preemptable invoke preemptable function of the plugins
func (ssn *Session) Preemptable(preemptor *api.TaskInfo, preemptees []*api.TaskInfo) []*api.TaskInfo {
var victims []*api.TaskInfo
var init bool

for _, tier := range ssn.Tiers {
for _, plugin := range tier.Plugins {
Expand All @@ -224,10 +222,9 @@ func (ssn *Session) Preemptable(preemptor *api.TaskInfo, preemptees []*api.TaskI
victims = nil
break
}

if !init {
// first iteration - initialize victims list
if victims == nil {
victims = candidates
init = true
} else {
var intersection []*api.TaskInfo
// Get intersection of victims and candidates.
Expand Down

0 comments on commit 21bb2da

Please sign in to comment.