Skip to content

Commit c1afd4d

Browse files
committed
Fix off-by-one in max-failures and docs
1 parent b60eef6 commit c1afd4d

File tree

3 files changed

+14
-11
lines changed

3 files changed

+14
-11
lines changed

README.md

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,6 @@ More documentation on specific topics can be [found here](./docs).
112112
## Manual
113113

114114
```
115-
116115
GIT-SYNC
117116
118117
NAME
@@ -266,10 +265,10 @@ OPTIONS
266265
Print this manual and exit.
267266
268267
--max-failures <int>, $GITSYNC_MAX_FAILURES
269-
The number of consecutive failures allowed before aborting (the
270-
first sync must succeed), Setting this to a negative value will
271-
retry forever after the initial sync. If not specified, this
272-
defaults to 0, meaning any sync failure will terminate git-sync.
268+
The number of consecutive failures allowed before aborting.
269+
Setting this to a negative value will retry forever. If not
270+
specified, this defaults to 0, meaning any sync failure will
271+
terminate git-sync.
273272
274273
--one-time, $GITSYNC_ONE_TIME
275274
Exit after one sync.

main.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -384,7 +384,7 @@ func main() {
384384
"sync on receipt of the specified signal (e.g. SIGHUP)")
385385
flMaxFailures := pflag.Int("max-failures",
386386
envInt(0, "GITSYNC_MAX_FAILURES", "GIT_SYNC_MAX_FAILURES"),
387-
"the number of consecutive failures allowed before aborting (the first sync must succeed, -1 will retry forever")
387+
"the number of consecutive failures allowed before aborting (-1 will retry forever")
388388
flTouchFile := pflag.String("touch-file",
389389
envString("", "GITSYNC_TOUCH_FILE", "GIT_SYNC_TOUCH_FILE"),
390390
"the path (absolute or relative to --root) to an optional file which will be touched whenever a sync completes (defaults to disabled)")
@@ -964,7 +964,7 @@ func main() {
964964
if changed, hash, err := git.SyncRepo(ctx, refreshCreds); err != nil {
965965
failCount++
966966
updateSyncMetrics(metricKeyError, start)
967-
if *flMaxFailures >= 0 && failCount > *flMaxFailures {
967+
if *flMaxFailures >= 0 && failCount >= *flMaxFailures {
968968
// Exit after too many retries, maybe the error is not recoverable.
969969
log.Error(err, "too many failures, aborting", "failCount", failCount)
970970
os.Exit(1)
@@ -2375,10 +2375,10 @@ OPTIONS
23752375
Print this manual and exit.
23762376
23772377
--max-failures <int>, $GITSYNC_MAX_FAILURES
2378-
The number of consecutive failures allowed before aborting (the
2379-
first sync must succeed), Setting this to a negative value will
2380-
retry forever after the initial sync. If not specified, this
2381-
defaults to 0, meaning any sync failure will terminate git-sync.
2378+
The number of consecutive failures allowed before aborting.
2379+
Setting this to a negative value will retry forever. If not
2380+
specified, this defaults to 0, meaning any sync failure will
2381+
terminate git-sync.
23822382
23832383
--one-time, $GITSYNC_ONE_TIME
23842384
Exit after one sync.

v3-to-v4.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,10 @@ The new name of this flag is shorter and captures the idea that any
8989
non-recoverable error in the sync loop counts as a failure. For backwards
9090
compatibility, `--max-sync-failures` will be used if it is specified.
9191

92+
git-sync v3 demanded that the first sync succeed, regardless of this flag.
93+
git-sync v4 always allows failures up to this maximum, whether it is the first
94+
sync or any other.
95+
9296
### Timeouts: `--timeout` -> `--sync-timeout`
9397

9498
The old `--timeout` flag took an integer number of seconds as an argument. The

0 commit comments

Comments
 (0)