From 4dc9a1b300b2f22dbd9628713917347bc0d3a6ee Mon Sep 17 00:00:00 2001 From: Evgenii Stratonikov <e.stratonikov@yadro.com> Date: Fri, 4 Oct 2024 15:07:20 +0300 Subject: [PATCH] [#1413] engine: Remove error counting methods from Shard All error counting and hangling logic is present on the engine level. Currently, we pass engine metrics with shard ID metric to shard, then export 3 methods to manipulate these metrics. In this commits all methods are removed and error counter is tracked on the engine level exlusively. Signed-off-by: Evgenii Stratonikov <e.stratonikov@yadro.com> --- pkg/local_object_storage/engine/engine.go | 2 +- pkg/local_object_storage/engine/shards.go | 6 +++--- pkg/local_object_storage/shard/metrics.go | 9 --------- pkg/local_object_storage/shard/shard.go | 12 ------------ 4 files changed, 4 insertions(+), 25 deletions(-) diff --git a/pkg/local_object_storage/engine/engine.go b/pkg/local_object_storage/engine/engine.go index f40c9cc04f..3183d61374 100644 --- a/pkg/local_object_storage/engine/engine.go +++ b/pkg/local_object_storage/engine/engine.go @@ -144,7 +144,7 @@ func (e *StorageEngine) reportShardError( } errCount := sh.errorCount.Add(1) - sh.Shard.IncErrorCounter() + e.metrics.IncErrorCounter(sh.ID().String()) sid := sh.ID() e.log.Warn(msg, append([]zap.Field{ diff --git a/pkg/local_object_storage/engine/shards.go b/pkg/local_object_storage/engine/shards.go index c3ccb52762..aab2c423c6 100644 --- a/pkg/local_object_storage/engine/shards.go +++ b/pkg/local_object_storage/engine/shards.go @@ -217,7 +217,7 @@ func (e *StorageEngine) removeShards(ids ...string) { continue } - sh.DeleteShardMetrics() + e.metrics.DeleteShardMetrics(id) ss = append(ss, sh) delete(e.shards, id) @@ -318,7 +318,7 @@ func (e *StorageEngine) SetShardMode(id *shard.ID, m mode.Mode, resetErrorCounte if id.String() == shID { if resetErrorCounter { sh.errorCount.Store(0) - sh.Shard.ClearErrorCounter() + e.metrics.ClearErrorCounter(shID) } return sh.SetMode(m) } @@ -422,7 +422,7 @@ func (e *StorageEngine) deleteShards(ids []*shard.ID) ([]hashedShard, error) { for _, sh := range ss { idStr := sh.ID().String() - sh.DeleteShardMetrics() + e.metrics.DeleteShardMetrics(idStr) delete(e.shards, idStr) diff --git a/pkg/local_object_storage/shard/metrics.go b/pkg/local_object_storage/shard/metrics.go index 6bf198048d..91bf8d0aef 100644 --- a/pkg/local_object_storage/shard/metrics.go +++ b/pkg/local_object_storage/shard/metrics.go @@ -24,12 +24,6 @@ type MetricsWriter interface { SetShardID(id string) // SetReadonly must set shard mode. SetMode(mode mode.Mode) - // IncErrorCounter increment error counter. - IncErrorCounter() - // ClearErrorCounter clear error counter. - ClearErrorCounter() - // DeleteShardMetrics deletes shard metrics from registry. - DeleteShardMetrics() // SetContainerObjectsCount sets container object count. SetContainerObjectsCount(cnrID string, objectType string, value uint64) // IncContainerObjectsCount increments container object count. @@ -57,9 +51,6 @@ func (noopMetrics) AddToPayloadSize(int64) {} func (noopMetrics) IncObjectCounter(string) {} func (noopMetrics) SetShardID(string) {} func (noopMetrics) SetMode(mode.Mode) {} -func (noopMetrics) IncErrorCounter() {} -func (noopMetrics) ClearErrorCounter() {} -func (noopMetrics) DeleteShardMetrics() {} func (noopMetrics) SetContainerObjectsCount(string, string, uint64) {} func (noopMetrics) IncContainerObjectsCount(string, string) {} func (noopMetrics) SubContainerObjectsCount(string, string, uint64) {} diff --git a/pkg/local_object_storage/shard/shard.go b/pkg/local_object_storage/shard/shard.go index a57b548be4..d7e7237339 100644 --- a/pkg/local_object_storage/shard/shard.go +++ b/pkg/local_object_storage/shard/shard.go @@ -494,18 +494,6 @@ func (s *Shard) setContainerObjectsCount(cnr string, typ string, v uint64) { } } -func (s *Shard) IncErrorCounter() { - s.cfg.metricsWriter.IncErrorCounter() -} - -func (s *Shard) ClearErrorCounter() { - s.cfg.metricsWriter.ClearErrorCounter() -} - -func (s *Shard) DeleteShardMetrics() { - s.cfg.metricsWriter.DeleteShardMetrics() -} - func (s *Shard) SetEvacuationInProgress(val bool) { s.m.Lock() defer s.m.Unlock()