diff --git a/cmd/git-sync/main.go b/cmd/git-sync/main.go index d9b5e31..3f05586 100644 --- a/cmd/git-sync/main.go +++ b/cmd/git-sync/main.go @@ -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())