Merge pull request #548 from thockin/v3-fail-count-logging

v3: Clean up fail-count logging
This commit is contained in:
Kubernetes Prow Robot 2022-07-02 03:51:24 -07:00 committed by GitHub
commit 114b30daa6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 6 additions and 4 deletions

View File

@ -520,16 +520,15 @@ func main() {
start := time.Now() start := time.Now()
ctx, cancel := context.WithTimeout(context.Background(), time.Second*time.Duration(*flSyncTimeout)) ctx, cancel := context.WithTimeout(context.Background(), time.Second*time.Duration(*flSyncTimeout))
if changed, hash, err := syncRepo(ctx, *flRepo, *flBranch, *flRev, *flDepth, *flRoot, *flDest, *flAskPassURL, *flSubmodules); err != nil { if changed, hash, err := syncRepo(ctx, *flRepo, *flBranch, *flRev, *flDepth, *flRoot, *flDest, *flAskPassURL, *flSubmodules); err != nil {
failCount++
updateSyncMetrics(metricKeyError, start) updateSyncMetrics(metricKeyError, start)
if *flMaxSyncFailures != -1 && failCount >= *flMaxSyncFailures { if *flMaxSyncFailures != -1 && failCount > *flMaxSyncFailures {
// Exit after too many retries, maybe the error is not recoverable. // Exit after too many retries, maybe the error is not recoverable.
log.Error(err, "too many failures, aborting", "failCount", failCount) log.Error(err, "too many failures, aborting", "failCount", failCount)
os.Exit(1) os.Exit(1)
} }
failCount++ log.Error(err, "unexpected error syncing repo, will retry", "failCount", failCount, "waitTime", waitTime(*flWait))
log.Error(err, "unexpected error syncing repo, will retry")
log.V(0).Info("waiting before retrying", "waitTime", waitTime(*flWait))
cancel() cancel()
time.Sleep(waitTime(*flWait)) time.Sleep(waitTime(*flWait))
continue continue
@ -581,6 +580,9 @@ func main() {
initialSync = false initialSync = false
} }
if failCount > 0 {
log.V(5).Info("resetting failure count", "failCount", failCount)
}
failCount = 0 failCount = 0
log.DeleteErrorFile() log.DeleteErrorFile()
log.V(1).Info("next sync", "wait_time", waitTime(*flWait)) log.V(1).Info("next sync", "wait_time", waitTime(*flWait))