forked from TrueCloudLab/frostfs-node
[#1437] node: Fix contextcheck linter
Signed-off-by: Dmitrii Stepanov <d.stepanov@yadro.com>
This commit is contained in:
parent
6921a89061
commit
7429553266
209 changed files with 1068 additions and 1036 deletions
|
@ -99,24 +99,24 @@ func (e *StorageEngine) moveToDegraded(ctx context.Context, sh *shard.Shard, err
|
|||
if isMeta {
|
||||
err := sh.SetMode(ctx, mode.DegradedReadOnly)
|
||||
if err == nil {
|
||||
log.Info(context.Background(), logs.EngineShardIsMovedInDegradedModeDueToErrorThreshold)
|
||||
log.Info(ctx, logs.EngineShardIsMovedInDegradedModeDueToErrorThreshold)
|
||||
return
|
||||
}
|
||||
log.Error(context.Background(), logs.EngineFailedToMoveShardInDegradedreadonlyModeMovingToReadonly,
|
||||
log.Error(ctx, logs.EngineFailedToMoveShardInDegradedreadonlyModeMovingToReadonly,
|
||||
zap.Error(err))
|
||||
}
|
||||
|
||||
err := sh.SetMode(ctx, mode.ReadOnly)
|
||||
if err != nil {
|
||||
log.Error(context.Background(), logs.EngineFailedToMoveShardInReadonlyMode, zap.Error(err))
|
||||
log.Error(ctx, logs.EngineFailedToMoveShardInReadonlyMode, zap.Error(err))
|
||||
return
|
||||
}
|
||||
|
||||
log.Info(context.Background(), logs.EngineShardIsMovedInReadonlyModeDueToErrorThreshold)
|
||||
log.Info(ctx, logs.EngineShardIsMovedInReadonlyModeDueToErrorThreshold)
|
||||
}
|
||||
|
||||
// reportShardErrorByID increases shard error counter and logs an error.
|
||||
func (e *StorageEngine) reportShardErrorByID(id string, msg string, err error) {
|
||||
func (e *StorageEngine) reportShardErrorByID(ctx context.Context, id string, msg string, err error) {
|
||||
e.mtx.RLock()
|
||||
sh, ok := e.shards[id]
|
||||
e.mtx.RUnlock()
|
||||
|
@ -125,19 +125,20 @@ func (e *StorageEngine) reportShardErrorByID(id string, msg string, err error) {
|
|||
return
|
||||
}
|
||||
|
||||
e.reportShardError(sh, msg, err)
|
||||
e.reportShardError(ctx, sh, msg, err)
|
||||
}
|
||||
|
||||
// reportShardError checks that the amount of errors doesn't exceed the configured threshold.
|
||||
// If it does, shard is set to read-only mode.
|
||||
func (e *StorageEngine) reportShardError(
|
||||
ctx context.Context,
|
||||
sh hashedShard,
|
||||
msg string,
|
||||
err error,
|
||||
fields ...zap.Field,
|
||||
) {
|
||||
if isLogical(err) {
|
||||
e.log.Warn(context.Background(), msg,
|
||||
e.log.Warn(ctx, msg,
|
||||
zap.Stringer("shard_id", sh.ID()),
|
||||
zap.String("error", err.Error()))
|
||||
return
|
||||
|
@ -147,7 +148,7 @@ func (e *StorageEngine) reportShardError(
|
|||
e.metrics.IncErrorCounter(sh.ID().String())
|
||||
|
||||
sid := sh.ID()
|
||||
e.log.Warn(context.Background(), msg, append([]zap.Field{
|
||||
e.log.Warn(ctx, msg, append([]zap.Field{
|
||||
zap.Stringer("shard_id", sid),
|
||||
zap.Uint32("error count", errCount),
|
||||
zap.String("error", err.Error()),
|
||||
|
@ -168,7 +169,7 @@ func (e *StorageEngine) reportShardError(
|
|||
default:
|
||||
// For background workers we can have a lot of such errors,
|
||||
// thus logging is done with DEBUG level.
|
||||
e.log.Debug(context.Background(), logs.EngineModeChangeIsInProgressIgnoringSetmodeRequest,
|
||||
e.log.Debug(ctx, logs.EngineModeChangeIsInProgressIgnoringSetmodeRequest,
|
||||
zap.Stringer("shard_id", sid),
|
||||
zap.Uint32("error_count", errCount))
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue