Merge pull request #133 from jacksontj/failure

Add option to allow for unlimited failures
This commit is contained in:
Kubernetes Prow Robot 2019-01-22 09:23:43 -08:00 committed by GitHub
commit 772c3b3078
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 2 additions and 2 deletions

View File

@ -58,7 +58,7 @@ var flSyncTimeout = flag.Int("timeout", envInt("GIT_SYNC_TIMEOUT", 120),
var flOneTime = flag.Bool("one-time", envBool("GIT_SYNC_ONE_TIME", false),
"exit after the initial checkout")
var flMaxSyncFailures = flag.Int("max-sync-failures", envInt("GIT_SYNC_MAX_SYNC_FAILURES", 0),
"the number of consecutive failures allowed before aborting (the first pull must succeed)")
"the number of consecutive failures allowed before aborting (the first pull must succeed, -1 disables aborting for any number of failures after the initial sync)")
var flChmod = flag.Int("change-permissions", envInt("GIT_SYNC_PERMISSIONS", 0),
"the file permissions to apply to the checked-out files")
@ -189,7 +189,7 @@ func main() {
for {
ctx, cancel := context.WithTimeout(context.Background(), time.Second*time.Duration(*flSyncTimeout))
if err := syncRepo(ctx, *flRepo, *flBranch, *flRev, *flDepth, *flRoot, *flDest); err != nil {
if initialSync || failCount >= *flMaxSyncFailures {
if initialSync || (*flMaxSyncFailures != -1 && failCount >= *flMaxSyncFailures) {
log.Errorf("error syncing repo: %v", err)
os.Exit(1)
}