Skip to content

Commit

Permalink
Removed init variable from Reclaimable and Preemptable parts of sessi…
Browse files Browse the repository at this point in the history
…on_plugin.

Signed-off-by: Piotr Ignatowski <piotr.ignatowski@ing.com>
  • Loading branch information
Piotr Ignatowski committed Oct 9, 2024
1 parent 41f6bfb commit 7976b63
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 7976b63

Please sign in to comment.