Skip to content

Commit

Permalink
Remove logic that remembers previous pool state (#3954)
Browse files Browse the repository at this point in the history
Signed-off-by: Chris Martin <chris@cmartinit.co.uk>
  • Loading branch information
d80tb7 authored Sep 19, 2024
1 parent bfc4975 commit 21d20ca
Showing 1 changed file with 5 additions and 15 deletions.
20 changes: 5 additions & 15 deletions internal/scheduler/scheduling_algo.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,6 @@ type FairSchedulingAlgo struct {
limiterByQueue map[string]*rate.Limiter
// Max amount of time each scheduling round is allowed to take.
maxSchedulingDuration time.Duration
// Pools that need to be scheduled in sorted order
poolsToSchedule []string
clock clock.Clock
resourceListFactory *internaltypes.ResourceListFactory
floatingResourceTypes *floatingresources.FloatingResourceTypes
Expand Down Expand Up @@ -117,23 +115,18 @@ func (l *FairSchedulingAlgo) Schedule(
return nil, err
}

if len(l.poolsToSchedule) == 0 {
// Cycle over groups in a consistent order.
l.poolsToSchedule = maps.Keys(fsctx.nodesByPoolAndExecutor)
sortGroups(l.poolsToSchedule, l.schedulingConfig.PoolSchedulePriority, l.schedulingConfig.DefaultPoolSchedulePriority)
}
pools := maps.Keys(fsctx.nodesByPoolAndExecutor)
sortGroups(pools, l.schedulingConfig.PoolSchedulePriority, l.schedulingConfig.DefaultPoolSchedulePriority)

ctx.Infof("Looping over pools %s", strings.Join(l.poolsToSchedule, " "))
for len(l.poolsToSchedule) > 0 {
ctx.Infof("Looping over pools %s", strings.Join(pools, " "))
for _, pool := range pools {
select {
case <-ctx.Done():
// We've reached the scheduling time limit; exit gracefully.
ctx.Info("ending scheduling round early as we have hit the maximum scheduling duration")
return overallSchedulerResult, nil
default:
}
pool := armadaslices.Pop(&l.poolsToSchedule)

nodeCountForPool := 0
for _, executor := range fsctx.executors {
nodeCountForPool += len(fsctx.nodesByPoolAndExecutor[pool][executor.Id])
Expand Down Expand Up @@ -162,11 +155,8 @@ func (l *FairSchedulingAlgo) Schedule(
err,
)

if err == context.DeadlineExceeded {
if errors.Is(err, context.DeadlineExceeded) {
// We've reached the scheduling time limit;
// add the executorGroupLabel back to l.poolsToSchedule such that we try it again next time,
// and exit gracefully.
l.poolsToSchedule = append(l.poolsToSchedule, pool)
ctx.Info("stopped scheduling early as we have hit the maximum scheduling duration")
break
} else if err != nil {
Expand Down

0 comments on commit 21d20ca

Please sign in to comment.