Skip to content

Commit

Permalink
improve readability
Browse files Browse the repository at this point in the history
  • Loading branch information
mimowo committed Jan 9, 2024
1 parent fce9ac3 commit b936787
Showing 1 changed file with 12 additions and 13 deletions.
25 changes: 12 additions & 13 deletions pkg/scheduler/preemption/preemption.go
Original file line number Diff line number Diff line change
Expand Up @@ -363,22 +363,21 @@ func workloadFits(wlReq cache.FlavorResourceQuantities, cq *cache.ClusterQueue,
for rName, rReq := range flvReq {
resource := flvQuotas.Resources[rName]

if cq.Cohort != nil {
if allowBorrowing {
// When resource.BorrowingLimit == nil there is no borrowing
// limit, so we can skip the check.
if resource.BorrowingLimit != nil {
if cqResUsage[rName]+rReq > resource.Nominal+*resource.BorrowingLimit {
return false
}
}
}
if cohortResUsage[rName]+rReq > cohortResRequestable[rName] {
if cq.Cohort == nil || !allowBorrowing {
if cqResUsage[rName]+rReq > resource.Nominal {
return false
}
} else {
// When resource.BorrowingLimit == nil there is no borrowing
// limit, so we can skip the check.
if resource.BorrowingLimit != nil {
if cqResUsage[rName]+rReq > resource.Nominal+*resource.BorrowingLimit {
return false
}
}
}
if cq.Cohort == nil || !allowBorrowing {
if cqResUsage[rName]+rReq > resource.Nominal {
if cq.Cohort != nil {
if cohortResUsage[rName]+rReq > cohortResRequestable[rName] {
return false
}
}
Expand Down

0 comments on commit b936787

Please sign in to comment.