DRA scheduler: refactor CEL compilation cache

A better place is the cel package because a) the name can become shorter
and b) it is tightly coupled with the compiler there.

Moving the compilation into the cache simplifies the callers.
This commit is contained in:
Patrick Ohly
2024-10-30 10:36:56 +01:00
parent 6f07fa3a5e
commit 7863d9a381
8 changed files with 188 additions and 84 deletions

View File

@@ -38,6 +38,7 @@ import (
resourcelisters "k8s.io/client-go/listers/resource/v1alpha3"
"k8s.io/client-go/util/retry"
"k8s.io/component-helpers/scheduling/corev1/nodeaffinity"
"k8s.io/dynamic-resource-allocation/cel"
"k8s.io/dynamic-resource-allocation/resourceclaim"
"k8s.io/dynamic-resource-allocation/structured"
"k8s.io/klog/v2"
@@ -111,7 +112,7 @@ type DynamicResources struct {
clientset kubernetes.Interface
classLister resourcelisters.DeviceClassLister
sliceLister resourcelisters.ResourceSliceLister
celCache *structured.CELCache
celCache *cel.Cache
allocatedDevices *allocatedDevices
// claimAssumeCache enables temporarily storing a newer claim object
@@ -192,7 +193,7 @@ func New(ctx context.Context, plArgs runtime.Object, fh framework.Handle, fts fe
// This is a LRU cache for compiled CEL expressions. The most
// recent 10 of them get reused across different scheduling
// cycles.
celCache: structured.NewCELCache(10),
celCache: cel.NewCache(10),
allocatedDevices: newAllocatedDevices(logger),
}