From 20b84f183a2936fe3b4522f13ee06468df63ef98 Mon Sep 17 00:00:00 2001 From: Evgenii Stratonikov Date: Thu, 15 Jun 2023 11:42:54 +0300 Subject: [PATCH] [#446] engine: Simplify logs for shard mode change Signed-off-by: Evgenii Stratonikov --- pkg/local_object_storage/engine/engine.go | 22 +++++++++------------- 1 file changed, 9 insertions(+), 13 deletions(-) diff --git a/pkg/local_object_storage/engine/engine.go b/pkg/local_object_storage/engine/engine.go index 7c36811e7..9967b2e2b 100644 --- a/pkg/local_object_storage/engine/engine.go +++ b/pkg/local_object_storage/engine/engine.go @@ -83,32 +83,28 @@ func (e *StorageEngine) setModeLoop() { } func (e *StorageEngine) moveToDegraded(sh *shard.Shard, errCount uint32) { + sid := sh.ID() + log := e.log.With( + zap.Stringer("shard_id", sid), + zap.Uint32("error count", errCount)) + e.mtx.RLock() defer e.mtx.RUnlock() - sid := sh.ID() err := sh.SetMode(mode.DegradedReadOnly) if err != nil { - e.log.Error(logs.EngineFailedToMoveShardInDegradedreadonlyModeMovingToReadonly, - zap.Stringer("shard_id", sid), - zap.Uint32("error count", errCount), + log.Error(logs.EngineFailedToMoveShardInDegradedreadonlyModeMovingToReadonly, zap.Error(err)) err = sh.SetMode(mode.ReadOnly) if err != nil { - e.log.Error(logs.EngineFailedToMoveShardInReadonlyMode, - zap.Stringer("shard_id", sid), - zap.Uint32("error count", errCount), + log.Error(logs.EngineFailedToMoveShardInReadonlyMode, zap.Error(err)) } else { - e.log.Info(logs.EngineShardIsMovedInReadonlyModeDueToErrorThreshold, - zap.Stringer("shard_id", sid), - zap.Uint32("error count", errCount)) + log.Info(logs.EngineShardIsMovedInReadonlyModeDueToErrorThreshold) } } else { - e.log.Info(logs.EngineShardIsMovedInDegradedModeDueToErrorThreshold, - zap.Stringer("shard_id", sid), - zap.Uint32("error count", errCount)) + log.Info(logs.EngineShardIsMovedInDegradedModeDueToErrorThreshold) } }