Clean up fail-count logging

Increment it before logging it!
This commit is contained in:
Tim Hockin 2022-06-14 13:46:41 -07:00
parent a4b3b3ff08
commit c9dca148d4
1 changed files with 6 additions and 4 deletions

View File

@ -628,16 +628,15 @@ func main() {
}
if changed, hash, err := git.SyncRepo(ctx); err != nil {
failCount++
updateSyncMetrics(metricKeyError, start)
if *flMaxSyncFailures != -1 && failCount >= *flMaxSyncFailures {
if *flMaxSyncFailures != -1 && failCount > *flMaxSyncFailures {
// Exit after too many retries, maybe the error is not recoverable.
log.Error(err, "too many failures, aborting", "failCount", failCount)
os.Exit(1)
}
failCount++
log.Error(err, "unexpected error syncing repo, will retry")
log.V(0).Info("waiting before retrying", "waitTime", flPeriod.String())
log.Error(err, "unexpected error syncing repo, will retry", "failCount", failCount, "waitTime", flPeriod.String())
cancel()
time.Sleep(*flPeriod)
continue
@ -689,6 +688,9 @@ func main() {
initialSync = false
}
if failCount > 0 {
log.V(5).Info("resetting failure count", "failCount", failCount)
}
failCount = 0
log.DeleteErrorFile()
log.V(1).Info("next sync", "waitTime", flPeriod.String())