Skip to content

Commit

Permalink
Squash duplicate errors in hammer (#250)
Browse files Browse the repository at this point in the history
  • Loading branch information
AlCutter authored Sep 12, 2024
1 parent d86e84c commit a984f59
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion hammer/hammer.go
Original file line number Diff line number Diff line change
Expand Up @@ -315,6 +315,8 @@ func (a *HammerAnalyser) updateStatsLoop(ctx context.Context) {
func (a *HammerAnalyser) errorLoop(ctx context.Context) {
tick := time.NewTicker(time.Second)
pbCount := 0
lastErr := ""
lastErrCount := 0
for {
select {
case <-ctx.Done(): //context cancelled
Expand All @@ -324,12 +326,24 @@ func (a *HammerAnalyser) errorLoop(ctx context.Context) {
klog.Warningf("%d requests received pushback from log", pbCount)
pbCount = 0
}
if lastErrCount > 0 {
klog.Warningf("(%d x) %s", lastErrCount, lastErr)
lastErrCount = 0

}
case err := <-a.errChan:
if errors.Is(err, ErrRetry) {
pbCount++
continue
}
klog.Warning(err)
es := err.Error()
if es != lastErr && lastErrCount > 0 {
klog.Warningf("(%d x) %s", lastErrCount, lastErr)
lastErr = es
lastErrCount = 0
continue
}
lastErrCount++
}
}
}
Expand Down

0 comments on commit a984f59

Please sign in to comment.