Skip to content

Commit

Permalink
fixup! fix: avoid resources lock contention utilizing channel
Browse files Browse the repository at this point in the history
  • Loading branch information
mpelekh committed Nov 12, 2024
1 parent 809ba43 commit d310961
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions pkg/cache/cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -1300,7 +1300,7 @@ func (c *clusterCache) recordEvent(event watch.EventType, un *unstructured.Unstr
}

func (c *clusterCache) processEvents() {
log := c.log.WithValues("fn", "processItems")
log := c.log.WithValues("functionName", "processItems")
log.V(1).Info("Start processing events")

c.lock.Lock()
Expand All @@ -1313,12 +1313,12 @@ func (c *clusterCache) processEvents() {

for {
select {
case em, ok := <-ch:
case evMeta, ok := <-ch:
if !ok {
log.V(1).Info("Event processing channel closed, finish processing")
log.V(2).Info("Event processing channel closed, finish processing")
return
}
eventMetas = append(eventMetas, em)
eventMetas = append(eventMetas, evMeta)
case <-ticker.C:
if len(eventMetas) > 0 {
c.processEventsBatch(eventMetas)
Expand All @@ -1329,7 +1329,7 @@ func (c *clusterCache) processEvents() {
}

func (c *clusterCache) processEventsBatch(eventMetas []eventMeta) {
log := c.log.WithValues("fn", "processEventsBatch")
log := c.log.WithValues("functionName", "processEventsBatch")
start := time.Now()
c.lock.Lock()
log.V(1).Info("Lock acquired (ms)", "duration", time.Since(start).Milliseconds())
Expand Down

0 comments on commit d310961

Please sign in to comment.