From 061657208526b527b47aa3ce5188eac1b8572ba2 Mon Sep 17 00:00:00 2001 From: Walther Lee Date: Thu, 5 Sep 2024 13:58:52 -0700 Subject: [PATCH] fix run condition in metrics handler Signed-off-by: Walther Lee --- pkg/metricshandler/metrics_handler.go | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/pkg/metricshandler/metrics_handler.go b/pkg/metricshandler/metrics_handler.go index 6ae02b7a4..525c87fc0 100644 --- a/pkg/metricshandler/metrics_handler.go +++ b/pkg/metricshandler/metrics_handler.go @@ -72,7 +72,10 @@ func New(opts *options.Options, kubeClient kubernetes.Interface, storeBuilder ks // ReconfigureSharding reconfigures sharding with the current shard and totalShards, and // it's a no-op if both values are 0. func (m *MetricsHandler) ReconfigureSharding(ctx context.Context) { - if m.curShard == 0 && m.curTotalShards == 0 { + m.mtx.RLock() + hasShardsSet := m.curShard != 0 || m.curTotalShards != 0 + m.mtx.RUnlock() + if !hasShardsSet { return } m.ConfigureSharding(ctx, m.curShard, m.curTotalShards)