diff options
| author | aur-build <aur-build@localhost> | 2026-11-18 17:43:25 +0000 |
|---|---|---|
| committer | aur-build <aur-build@localhost> | 2026-11-18 17:43:25 +0000 |
| commit | 7587284ae48fb59c59da33af928322e8a621f4b0 (patch) | |
| tree | 3426d4d3e2319374a387a636468ac247c9743480 /src/error.rs | |
| parent | f3e4c1496d2ddcdae535132427fdb499181f1695 (diff) | |
| download | aur-build-7587284ae48fb59c59da33af928322e8a621f4b0.tar.gz aur-build-7587284ae48fb59c59da33af928322e8a621f4b0.zip | |
pipeline, db: the correctness minors — fsync, withdrawal, orphans, retry class
m-7. `fsync_file` and `fsync_dir` opened, ignored every error, and returned Ok,
in the module whose entire guarantee is "fsync, then rename". A filesystem that
refused the sync — full, read-only, a network mount that had dropped — still
produced a successful publish whose database might not be on disk. They
propagate now, with the path and the cause.
m-10. `withdraw_release_in` set `state='withdrawn'` unconditionally, so
withdrawing twice reported success the second time while changing nothing, and
withdrawing a release that had never been live did the same. The write is a
compare-and-swap on `state='published'`, and a refusal names the state that was
actually there ("release 1 is withdrawn, not published: nothing to withdraw").
m-16. Artifacts are copied into the served tree before the DB commit, and when
the commit refused they stayed: files no index names, sitting in the directory
consumers download from. `publish` now tracks which files it created (a file
that already existed belongs to the release still being served and is never
touched) and removes them if the publish does not land.
m-14. `is_transient` treated every `Error::Io` as retryable, which made ENOSPC
and EACCES — plain `Io` — into three identical failures and a silent build.
Only the kinds that mean "ask again in a moment" retry now. This turned a test
that had been asserting the bug: it simulated a transient failure by pointing
`makechrootpkg` at a nonexistent path, which is a missing binary, not a flaky
network. That test now asserts the opposite (one attempt, no retries), and a new
one produces a genuinely transient failure the way production does — a `SKIP`
source whose bytes go unreachable after detection, cache dropped, so the
`sources` step fails over the fetch path and retries to the cap.
m-13. `random_hex` read `/dev/urandom` into a zeroed buffer, ignored every
error, and hashed it anyway. Since C-1 the session id is the whole credential,
so a failed read is now a refusal: `new_session()` returns `Option`, and the two
call sites answer 500 rather than mint a token derivable from the clock and a
counter.
m-9. The row-error policy is decided and applied: a row that cannot be read
fails the query instead of vanishing from the result (six `filter_map(|r|
r.ok())` sites, including the reaper's and the claimer's), and `setting_i64`
documents its own policy — absent means default, nonsense means default *and a
complaint*, because a typo that silently does nothing is worse than a knob that
refuses to apply.
Diffstat (limited to 'src/error.rs')
| -rw-r--r-- | src/error.rs | 51 |
1 files changed, 48 insertions, 3 deletions
diff --git a/src/error.rs b/src/error.rs index ac47fc8..cf6e567 100644 --- a/src/error.rs +++ b/src/error.rs @@ -68,11 +68,56 @@ impl Error { Error::Transient(s.to_string()) } - /// True when a retry could plausibly help (network, mirror 5xx). Deterministic - /// build failures must not auto-retry (§8.4). + /// True when a retry could plausibly help (§8.4): an unreachable upstream, a + /// mirror that 5xx'd, a connection that reset. + /// + /// `Error::Io` is *not* automatically transient (m-14). `ENOSPC` and + /// `EACCES` are `Io`, and treating them as retryable meant a full disk or a + /// misconfigured root turned into three identical failures, a shrug, and a + /// build that never got the operator's attention. Only the kinds that mean + /// "the same call might work in a moment" are retried. pub fn is_transient(&self) -> bool { - matches!(self, Error::Http(_) | Error::Io(_) | Error::Transient(_)) + match self { + Error::Http(_) | Error::Transient(_) => true, + Error::Io(e) => matches!( + e.kind(), + std::io::ErrorKind::WouldBlock + | std::io::ErrorKind::TimedOut + | std::io::ErrorKind::Interrupted + | std::io::ErrorKind::BrokenPipe + | std::io::ErrorKind::ConnectionReset + | std::io::ErrorKind::ConnectionRefused + | std::io::ErrorKind::ConnectionAborted + ), + _ => false, + } } } pub type Result<T> = std::result::Result<T, Error>; + +#[cfg(test)] +mod tests { + use super::*; + + #[test] + fn a_full_disk_is_not_a_retryable_failure() { + // m-14: `Error::Io` used to mean "retry", so ENOSPC and EACCES — both + // plain `Io` — turned into three identical failures and a build that + // never announced itself as broken. + let enospc = Error::Io(std::io::Error::from_raw_os_error(28)); + let eacces = Error::Io(std::io::Error::from_raw_os_error(13)); + assert!(!enospc.is_transient(), "a full disk does not clear itself between retries"); + assert!(!eacces.is_transient(), "a permissions problem does not clear itself either"); + } + + #[test] + fn what_a_moment_might_fix_is_retried() { + let refused = Error::Io(std::io::Error::from_raw_os_error(111)); + assert!(refused.is_transient()); + assert!(Error::transient("mirror returned 502").is_transient()); + assert!(Error::Http("connection reset".into()).is_transient()); + assert!(!Error::invalid("recipe has no pkgbase").is_transient()); + assert!(!Error::fail_closed("identity hash moved").is_transient()); + } +} |
