Skip to content

Commit

Permalink
Logging: log syncCount and be less scary
Browse files Browse the repository at this point in the history
  • Loading branch information
thockin committed Oct 14, 2023
1 parent 8fa652d commit b69d0f3
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -771,7 +771,7 @@ func main() {
}

failCount := 0
firstLoop := true
syncCount := uint64(0)
for {
start := time.Now()
ctx, cancel := context.WithTimeout(context.Background(), *flSyncTimeout)
Expand All @@ -789,7 +789,7 @@ func main() {
// this might have been called before, but also might not have
setRepoReady()
// We treat the first loop as a sync, including sending hooks.
if changed || firstLoop {
if changed || syncCount == 0 {
if absTouchFile != "" {
if err := touch(absTouchFile); err != nil {
log.Error(err, "failed to touch touch-file", "path", absTouchFile)
Expand All @@ -807,7 +807,7 @@ func main() {
} else {
updateSyncMetrics(metricKeyNoOp, start)
}
firstLoop = false
syncCount++

// Clean up old worktree(s) and run GC.
if err := git.cleanup(ctx); err != nil {
Expand Down Expand Up @@ -852,7 +852,7 @@ func main() {
log.DeleteErrorFile()
}

log.V(3).Info("next sync", "waitTime", flPeriod.String())
log.V(3).Info("next sync", "waitTime", flPeriod.String(), "syncCount", syncCount)
cancel()

// Sleep until the next sync. If syncSig is set then the sleep may
Expand Down Expand Up @@ -1076,7 +1076,7 @@ func (git *repoSync) initRepo(ctx context.Context) error {
// the contents rather than the dir itself, because a common use-case
// is to have a volume mounted at git.root, which makes removing it
// impossible.
git.log.V(0).Info("repo directory failed checks or was empty", "path", git.root)
git.log.V(0).Info("repo directory was empty or failed checks", "path", git.root)
if err := removeDirContents(git.root, git.log); err != nil {
return fmt.Errorf("can't wipe unusable root directory: %w", err)
}
Expand Down

0 comments on commit b69d0f3

Please sign in to comment.