@@ -150,7 +150,12 @@ type GpuAllocator struct {
150150 indexAllocator * indexallocator.IndexAllocator
151151}
152152
153- func NewGpuAllocator (ctx context.Context , client client.Client , syncInterval time.Duration ) * GpuAllocator {
153+ func NewGpuAllocator (
154+ ctx context.Context ,
155+ indexAllocator * indexallocator.IndexAllocator ,
156+ client client.Client ,
157+ syncInterval time.Duration ,
158+ ) * GpuAllocator {
154159 log := log .FromContext (ctx )
155160
156161 if client == nil {
@@ -166,6 +171,15 @@ func NewGpuAllocator(ctx context.Context, client client.Client, syncInterval tim
166171 // Create quota store
167172 quotaStore := quota .NewQuotaStore (client , ctx )
168173
174+ if indexAllocator == nil {
175+ newIndexAllocator , err := indexallocator .NewIndexAllocator (ctx , client )
176+ if err != nil {
177+ log .Error (err , "Failed to create index allocator" )
178+ return nil
179+ }
180+ indexAllocator = newIndexAllocator
181+ }
182+
169183 allocator := & GpuAllocator {
170184 Client : client ,
171185 filterRegistry : baseRegistry ,
@@ -178,6 +192,7 @@ func NewGpuAllocator(ctx context.Context, client client.Client, syncInterval tim
178192 dirtyQueue : make (map [types.NamespacedName ]struct {}),
179193 ctx : ctx ,
180194
195+ indexAllocator : indexAllocator ,
181196 uniqueAllocation : make (map [string ]* tfv1.AllocRequest , 512 ),
182197 uniqueDeallocation : make (map [string ]struct {}, 512 ),
183198 podNamespaceNsToPodUID : make (map [string ]string , 512 ),
0 commit comments