Merge pull request #134797 from aditigupta96/fix-runwithcontext-dra

dra: Use context-aware client-go informer functions
This commit is contained in:
Kubernetes Prow Robot
2025-10-23 01:53:05 -07:00
committed by GitHub

View File

@@ -479,7 +479,7 @@ func (c *Controller) initInformer(ctx context.Context) error {
indexers,
)
c.sliceStore = cache.NewIntegerResourceVersionMutationCache(logger, informer.GetStore(), informer.GetIndexer(), c.mutationCacheTTL, true /* includeAdds */)
handler, err := informer.AddEventHandler(cache.ResourceEventHandlerFuncs{
handler, err := informer.AddEventHandlerWithOptions(cache.ResourceEventHandlerFuncs{
AddFunc: func(obj any) {
slice, ok := obj.(*resourceapi.ResourceSlice)
if !ok {
@@ -522,7 +522,7 @@ func (c *Controller) initInformer(ctx context.Context) error {
c.queue.AddAfter(slice.Spec.Pool.Name, c.syncDelay)
logger.V(5).Info("Scheduled sync", "poolName", slice.Spec.Pool.Name, "at", time.Now().Add(c.syncDelay))
},
})
}, cache.HandlerOptions{Logger: &logger})
if err != nil {
return fmt.Errorf("registering event handler on the ResourceSlice informer: %w", err)
}
@@ -533,7 +533,7 @@ func (c *Controller) initInformer(ctx context.Context) error {
defer c.wg.Done()
defer logger.V(3).Info("ResourceSlice informer has stopped")
defer c.queue.ShutDown() // Once we get here, we must have been asked to stop.
informer.Run(ctx.Done())
informer.RunWithContext(ctx)
}()
for !handler.HasSynced() {
select {