feat: retry failed targets and classify transient failures as user errors#622
Merged
Merged
Conversation
…rors Add a 'retries' policy property (default 1) so an individual target that fails is retried before the error is reported, smoothing over transient network and remote-side failures. Retries apply per-target and compose with the existing git auto-recovery behaviour. Reclassify transient, user-facing failures from System to User errors so they are no longer reported as bugs via telemetry: - reqwest timeouts and request/connection failures (e.g. connection reset) - git clone/prepare failures (network and pack errors)
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #622 +/- ##
==========================================
+ Coverage 74.43% 76.83% +2.40%
==========================================
Files 31 31
Lines 2394 2612 +218
==========================================
+ Hits 1782 2007 +225
+ Misses 612 605 -7 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
Clippy's useless_borrows_in_formatting lint (denied in CI via -D warnings on the newer stable toolchain) flags redundant & borrows in format! arguments. Drop them so 'cargo clippy --all-targets --all-features -- -D warnings' passes.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Overview
Two related improvements to how the backup engine handles transient, user-facing failures (dropped/reset connections, timeouts, and git pack errors) which were previously surfaced as
Systemerrors and reported as bugs.1. Retries in the policy system
retriespolicy property (default1), read viaBackupPolicy::retries().Pairing::run_all_backupsretries each target backup up toretries + 1times before reporting the failure, skipping further attempts if the backup is cancelled.retriesvalues are rejected as aUsererror.2. Reclassify transient failures as
UsererrorsPreviously these tripped
error.is(Kind::System)inmain.rs, firingrecord_custom_errortelemetry and telling users to report a bug. They are nowUsererrors:src/errors.rs(reqwest::Error):is_timeout()andis_request()(e.g. connection reset / dropped send) now map towrap_userinstead ofwrap_system. This covers every reqwest call site (GitHub client, Forgejo client, HTTP file downloads).is_decodeand genuinely unknown errors remainSystem.src/engines/git.rs:prepare_cloneandfetch_only(the "Failed to consume the pack sent by the remote" case) changed fromwrap_system_err→wrap_user_err, matching the existing fetch path. Local disk/config writes remainSystem.Examples now classified as User errors
Tests
policy.rs: retries default / configured / zero (disabled) / invalid.pairing.rs: recover-after-retry, give-up-after-budget, retries disabled, invalid-property reporting (via a flaky mock engine).errors.rs: timeout →User(wiremock delayed response + short client timeout) and connect-failure →User.All 152 tests pass;
cargo fmt --checkandcargo clippy --all-targetsare clean.Docs
docs/advanced/retries.md, registered in the VuePress navbar + sidebar.Note for reviewers
retriesis implemented via the existingpropertiesmap (likerecovery/refspecs) and defaults to 1 retry globally. Happy to change it to opt-in (default 0) or promote it to a first-classBackupPolicyfield if preferred.