sync: Summarize what a sync cycle reached - #496
chucklever wants to merge 1 commit into
Conversation
|
Note This review was prepared with the assistance of an AI code review pair. Hi @chucklever, thanks for this PR! The motivation makes total sense—having the sync worker report a clean completion when network outages cause remotes to silently fall back to stale local refs can be very misleading in production. During a detailed review of the diff, a few issues came up (including one security consideration regarding credential redaction) that would be great to address: 1. Security: Credential Sanitization in
|
A cycle that reaches no remote at all closes with "Sync cycle complete", the same line a healthy cycle writes. The failures are there, one per remote and three journal lines each, but the state they add up to is recorded nowhere. One minute of a network outage, with every fetch failing, put 116 lines in the journal and named no condition. Counting failed returns would not name it either. A fetch that fails against a remote whose local ref is recent enough falls back to that ref and returns success, which is the path most remotes take when the network is down. Have ensure_remote report what happened, count the outcomes, and close the cycle on them. A remote nothing went out to, because its fetch interval had not elapsed or because a recent failure is backing off, is counted apart from the ones that answered. The backoff used to return an error, which counted a remote a review had failed to fetch within the hour as failed on a network that had recovered. It still returns one, of its own type, for a remote whose local ref is missing or older than the fallback window, since that remote has nothing for a caller to fall back on. The sync worker counts that return as backing off, because nothing went out to the remote. The fallback carries git's message out with it, because a cycle where every remote fell back has no failed return to quote. A remote whose URL cannot be read counts as failed, so the summary reconciles with the number of remotes found. A cycle that tries a remote and fetches none logs at error with the first failure, so the state takes one line an hour rather than a reader inferring it from the volume. A cycle can also find every remote backing off and try nothing. The worker's own failures are an hour old by its next cycle, past the backoff window, so those are fetches a review or a baseline lookup failed within the hour. That is the same outage, so it logs at warn rather than closing as a clean cycle. Signed-off-by: Chuck Lever <cel@kernel.org>
0096992 to
81778ec
Compare
|
Fixed all four in the updated branch.
|
A sync cycle that reaches no remote at all closes with "Sync cycle
complete", the same line a healthy cycle writes. The per-remote
failures are in the journal, three lines each, but the state they add
up to is recorded nowhere. One minute of a network outage put 116
lines in the journal and named no condition.
Counting failed returns would not name it either. A fetch that fails
against a remote whose local ref is recent enough falls back to that
ref and returns success, which is the path most remotes take when the
network is down. So ensure_remote now reports what happened rather
than whether it succeeded, and the cycle closes on a count of those
outcomes.
Two choices in the diff are worth a look. A remote nothing went out
to, because its fetch interval had not elapsed or a recent failure is
backing off, is counted apart from the ones that answered. The backoff
used to return an error, which would have made the cycle after an
outage report every remote as failed on a network that had recovered.
And the fallback path carries git's message out with it, because a
cycle where every remote fell back has no failed return to quote.
A cycle that tries more than one remote and fetches none logs at error
with the first failure. One remote tried and lost is that remote's
condition, and its own line already names it.
Verified standalone on top of e38762e: sign-off valid, clippy
clean, 514 unit and 39 integration tests passing.