Skip to content

Commit

Permalink
scheduler: optimize when only 1 reservation/node (#2136)
Browse files Browse the repository at this point in the history
Signed-off-by: wangjianyu.wjy <wangjianyu.wjy@alibaba-inc.com>
Co-authored-by: wangjianyu.wjy <wangjianyu.wjy@alibaba-inc.com>
  • Loading branch information
ZiMengSheng and wangjianyu.wjy committed Jul 17, 2024
1 parent 290ae09 commit beac34f
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions pkg/scheduler/plugins/reservation/nominator.go
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,10 @@ func (pl *Plugin) NominateReservation(ctx context.Context, cycleState *framework
return nil, nil
}

if len(reservationInfos) == 1 && state.hasAffinity {
return reservationInfos[0], nil
}

rInfo := pl.GetNominatedReservation(pod, nodeName)
if rInfo != nil {
return rInfo, nil
Expand All @@ -164,6 +168,10 @@ func (pl *Plugin) NominateReservation(ctx context.Context, cycleState *framework
return nil, nil
}

if len(reservations) == 1 {
return reservations[0], nil
}

nominated, _ := findMostPreferredReservationByOrder(reservations)
if nominated != nil {
return nominated, nil
Expand Down

0 comments on commit beac34f

Please sign in to comment.