Don't block on hooks when already synced + one-time

This commit is contained in:
Tim Hockin 2023-06-27 12:37:35 -07:00
parent a497b98c76
commit dec45c3caa
1 changed files with 29 additions and 27 deletions

View File

@ -566,16 +566,16 @@ func main() {
} else { } else {
updateSyncMetrics(metricKeyNoOp, start) updateSyncMetrics(metricKeyNoOp, start)
} }
}
if initialSync { if initialSync {
// Determine if git-sync should terminate for one of several reasons // Determine if git-sync should terminate for one of several reasons
if *flOneTime { if *flOneTime {
exitCode := 0 // is 0 if all hooks succeed, else is 1
if changed {
// Wait for hooks to complete at least once, if not nil, before // Wait for hooks to complete at least once, if not nil, before
// checking whether to stop program. // checking whether to stop program.
// Assumes that if hook channels are not nil, they will have at // Assumes that if hook channels are not nil, they will have at
// least one value before getting closed // least one value before getting closed
exitCode := 0 // is 0 if all hooks succeed, else is 1
if exechookRunner != nil { if exechookRunner != nil {
if err := exechookRunner.WaitForCompletion(); err != nil { if err := exechookRunner.WaitForCompletion(); err != nil {
exitCode = 1 exitCode = 1
@ -586,6 +586,7 @@ func main() {
exitCode = 1 exitCode = 1
} }
} }
}
log.DeleteErrorFile() log.DeleteErrorFile()
os.Exit(exitCode) os.Exit(exitCode)
} }
@ -599,6 +600,7 @@ func main() {
} }
initialSync = false initialSync = false
} }
}
if failCount > 0 { if failCount > 0 {
log.V(5).Info("resetting failure count", "failCount", failCount) log.V(5).Info("resetting failure count", "failCount", failCount)