Skip to content

Commit e2fd95f

Browse files
KunWuLuanlucming
authored andcommitted
koord-scheduler: retrieve reservationInfo from cache first in preFilter hook (koordinator-sh#906)
Signed-off-by: KunWuLuan <kunwuluan@gmail.com>
1 parent 9b64912 commit e2fd95f

File tree

3 files changed

+14
-2
lines changed

3 files changed

+14
-2
lines changed

pkg/scheduler/plugins/reservation/hook.go

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -153,6 +153,7 @@ func (h *Hook) prepareMatchReservationState(handle frameworkext.ExtendedHandle,
153153
klog.V(6).InfoS("PreFilterHook indexer list reservation on node",
154154
"node", node.Name, "count", len(rOnNode))
155155
count := 0
156+
rCache := getReservationCache()
156157
for _, obj := range rOnNode {
157158
r, ok := obj.(*schedulingv1alpha1.Reservation)
158159
if !ok {
@@ -163,7 +164,12 @@ func (h *Hook) prepareMatchReservationState(handle frameworkext.ExtendedHandle,
163164
if !util.IsReservationAvailable(r) {
164165
continue
165166
}
166-
if matchReservation(pod, newReservationInfo(r)) {
167+
168+
rInfo := rCache.GetInCache(r)
169+
if rInfo == nil {
170+
rInfo = newReservationInfo(r)
171+
}
172+
if matchReservation(pod, rInfo) {
167173
matchedCache.Add(r)
168174
count++
169175
} else {

pkg/scheduler/plugins/reservation/plugin.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ func New(args runtime.Object, handle framework.Handle) (framework.Plugin, error)
117117
podLister: extendedHandle.SharedInformerFactory().Core().V1().Pods().Lister(),
118118
client: extendedHandle.KoordinatorClientSet().SchedulingV1alpha1(),
119119
parallelizeUntil: defaultParallelizeUntil(handle),
120-
reservationCache: newReservationCache(),
120+
reservationCache: getReservationCache(),
121121
}
122122

123123
// handle reservation event in cache; here only scheduled and expired reservations are considered.

pkg/scheduler/plugins/reservation/rcache.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -228,6 +228,12 @@ type reservationCache struct {
228228
assumed map[string]*assumedInfo // reservation key -> assumed (pod allocated) reservation meta
229229
}
230230

231+
var rCache *reservationCache = newReservationCache()
232+
233+
func getReservationCache() *reservationCache {
234+
return rCache
235+
}
236+
231237
func newReservationCache() *reservationCache {
232238
return &reservationCache{
233239
inactive: map[string]*schedulingv1alpha1.Reservation{},

0 commit comments

Comments
 (0)