Skip to content

Logging: log syncCount and be less scary #835

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Oct 14, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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