Skip to content

Commit

Permalink
Avoid divide by zero
Browse files Browse the repository at this point in the history
  • Loading branch information
severinson committed Jun 27, 2023
1 parent 3d1cd09 commit 631ad72
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
5 changes: 4 additions & 1 deletion internal/armada/server/lease.go
Original file line number Diff line number Diff line change
Expand Up @@ -469,7 +469,10 @@ func (q *AggregatedQueueServer) getJobs(ctx context.Context, req *api.StreamingL
schedulerobjects.ResourceList{Resources: totalCapacity},
)
for queue, priorityFactor := range priorityFactorByQueue {
weight := 1 / priorityFactor
var weight float64 = 1
if priorityFactor > 0 {
weight = 1 / priorityFactor
}
if err := sctx.AddQueueSchedulingContext(queue, weight, allocatedByQueueAndPriorityClassForPool[queue]); err != nil {
return nil, err
}
Expand Down
5 changes: 4 additions & 1 deletion internal/scheduler/scheduling_algo.go
Original file line number Diff line number Diff line change
Expand Up @@ -327,7 +327,10 @@ func (l *FairSchedulingAlgo) scheduleOnExecutor(
if allocatedByQueueAndPriorityClass := accounting.allocationByPoolAndQueueAndPriorityClass[executor.Pool]; allocatedByQueueAndPriorityClass != nil {
allocatedByPriorityClass = allocatedByQueueAndPriorityClass[queue]
}
weight := 1 / priorityFactor
var weight float64 = 1
if priorityFactor > 0 {
weight = 1 / priorityFactor
}
if err := sctx.AddQueueSchedulingContext(queue, weight, allocatedByPriorityClass); err != nil {
return nil, nil, err
}
Expand Down

0 comments on commit 631ad72

Please sign in to comment.