Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion pkg/scheduler/plugins/reservation/hook.go
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,7 @@ func (h *Hook) prepareMatchReservationState(handle frameworkext.ExtendedHandle,
klog.V(6).InfoS("PreFilterHook indexer list reservation on node",
"node", node.Name, "count", len(rOnNode))
count := 0
rCache := getReservationCache()
for _, obj := range rOnNode {
r, ok := obj.(*schedulingv1alpha1.Reservation)
if !ok {
Expand All @@ -163,7 +164,12 @@ func (h *Hook) prepareMatchReservationState(handle frameworkext.ExtendedHandle,
if !util.IsReservationAvailable(r) {
continue
}
if matchReservation(pod, newReservationInfo(r)) {

rInfo := rCache.GetInCache(r)
if rInfo == nil {
rInfo = newReservationInfo(r)
}
if matchReservation(pod, rInfo) {
matchedCache.Add(r)
count++
} else {
Expand Down
2 changes: 1 addition & 1 deletion pkg/scheduler/plugins/reservation/plugin.go
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ func New(args runtime.Object, handle framework.Handle) (framework.Plugin, error)
podLister: extendedHandle.SharedInformerFactory().Core().V1().Pods().Lister(),
client: extendedHandle.KoordinatorClientSet().SchedulingV1alpha1(),
parallelizeUntil: defaultParallelizeUntil(handle),
reservationCache: newReservationCache(),
reservationCache: getReservationCache(),
}

// handle reservation event in cache; here only scheduled and expired reservations are considered.
Expand Down
6 changes: 6 additions & 0 deletions pkg/scheduler/plugins/reservation/rcache.go
Original file line number Diff line number Diff line change
Expand Up @@ -228,6 +228,12 @@ type reservationCache struct {
assumed map[string]*assumedInfo // reservation key -> assumed (pod allocated) reservation meta
}

var rCache *reservationCache = newReservationCache()

func getReservationCache() *reservationCache {
return rCache
}

func newReservationCache() *reservationCache {
return &reservationCache{
inactive: map[string]*schedulingv1alpha1.Reservation{},
Expand Down