From 564e0576cc70b395c5accbe66bfe70bbdf2349a6 Mon Sep 17 00:00:00 2001 From: Nick Pillitteri Date: Fri, 5 Apr 2024 09:27:15 -0400 Subject: [PATCH] Code review Signed-off-by: Nick Pillitteri --- internal/component/mimir/rules/kubernetes/events.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/internal/component/mimir/rules/kubernetes/events.go b/internal/component/mimir/rules/kubernetes/events.go index 2ff388d65063..c3d42114bfdd 100644 --- a/internal/component/mimir/rules/kubernetes/events.go +++ b/internal/component/mimir/rules/kubernetes/events.go @@ -46,7 +46,7 @@ type eventProcessor struct { logger log.Logger currentState kubernetes.RuleGroupsByNamespace - currentStateMtx sync.Mutex + currentStateMtx sync.RWMutex } func (e *eventProcessor) run(ctx context.Context) { @@ -237,8 +237,8 @@ func (e *eventProcessor) applyChanges(ctx context.Context, namespace string, dif // getMimirState returns the cached Mimir ruler state, rule groups indexed by Mimir namespace. func (e *eventProcessor) getMimirState() kubernetes.RuleGroupsByNamespace { - e.currentStateMtx.Lock() - defer e.currentStateMtx.Unlock() + e.currentStateMtx.RLock() + defer e.currentStateMtx.RUnlock() out := make(kubernetes.RuleGroupsByNamespace, len(e.currentState)) for ns, groups := range e.currentState {