policer: add check for repeated error logging #914
1 changed files with 16 additions and 1 deletions
|
@ -7,6 +7,7 @@ import (
|
|||
|
||||
"git.frostfs.info/TrueCloudLab/frostfs-node/internal/logs"
|
||||
"git.frostfs.info/TrueCloudLab/frostfs-node/pkg/local_object_storage/engine"
|
||||
cid "git.frostfs.info/TrueCloudLab/frostfs-sdk-go/container/id"
|
||||
"go.uber.org/zap"
|
||||
)
|
||||
|
||||
|
@ -34,6 +35,9 @@ func (p *Policer) shardPolicyWorker(ctx context.Context) {
|
|||
p.log.Warn(logs.PolicerFailureAtObjectSelectForReplication, zap.Error(err))
|
||||
}
|
||||
|
||||
// contains all errors logged in this iteration for each container
|
||||
cnrErrSkip := make(map[cid.ID][]error)
|
||||
|
||||
for i := range addrs {
|
||||
select {
|
||||
case <-ctx.Done():
|
||||
|
@ -55,10 +59,12 @@ func (p *Policer) shardPolicyWorker(ctx context.Context) {
|
|||
|
||||
if p.objsInWork.add(addr.Address) {
|
||||
err := p.processObject(ctx, addr)
|
||||
if err != nil {
|
||||
if err != nil && !skipLog(cnrErrSkip[addr.Address.Container()], err) {
|
||||
p.log.Error(logs.PolicerUnableToProcessObj,
|
||||
zap.Stringer("object", addr.Address),
|
||||
zap.String("error", err.Error()))
|
||||
|
||||
cnrErrSkip[addr.Address.Container()] = append(cnrErrSkip[addr.Address.Container()], err)
|
||||
}
|
||||
p.cache.Add(addr.Address, time.Now())
|
||||
p.objsInWork.remove(addr.Address)
|
||||
|
@ -72,3 +78,12 @@ func (p *Policer) shardPolicyWorker(ctx context.Context) {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
func skipLog(errs []error, err error) bool {
|
||||
for _, e := range errs {
|
||||
if errors.Is(err, e) {
|
||||
return true
|
||||
}
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue