summaryrefslogtreecommitdiffstats
path: root/src/pipeline/steps.rs
diff options
context:
space:
mode:
authoraur-build <aur-build@localhost>2026-11-19 12:00:46 +0000
committeraur-build <aur-build@localhost>2026-11-19 12:00:46 +0000
commitfa921c26bade47634506b57b32713421f976ae22 (patch)
tree77738f67fdf641c8a51dc070a3c628c5922be46e /src/pipeline/steps.rs
parent2eb4500f089154b982f7c5dbbc7f1efbfd702ed5 (diff)
downloadaur-build-fa921c26bade47634506b57b32713421f976ae22.tar.gz
aur-build-fa921c26bade47634506b57b32713421f976ae22.zip
sandbox: failure-mode tier — a FakeBackend that breaks on purpose
The recovery paths a remote pool makes newly reachable are now executed, not described. A decorator over the loopback backend injects the four faults that matter: a sandbox that vanishes mid-run (the step fails, the lease expires, the reaper requeues, a healthy pool finishes from the checkpoints — I5 across the sandbox boundary); a TTL that bites mid-build (a failed step, not a retry-burned one); a pool at quota (the build blocks on sandbox-pool using the same blocked machinery as missing deps, rather than failing on an infrastructure fact); and a sandbox whose pacman -Q lies about the installed world (provisioning refuses with a dedicated world-mismatch class, so 'the sandbox lied' never reads as 'the sandbox broke'). Two error classes carry that vocabulary: PoolExhausted — capacity, so wait, never retry — and WorldMismatch — fail-closed, never retried. The remote and kata acquire timeouts now speak the first, which is what makes a full pool a queue fact instead of a build failure.
Diffstat (limited to 'src/pipeline/steps.rs')
-rw-r--r--src/pipeline/steps.rs33
1 files changed, 29 insertions, 4 deletions
diff --git a/src/pipeline/steps.rs b/src/pipeline/steps.rs
index c989476..59c9a64 100644
--- a/src/pipeline/steps.rs
+++ b/src/pipeline/steps.rs
@@ -130,7 +130,10 @@ fn provision(ctx: &Ctx) -> Result<StepResult> {
if lease.is_empty() {
return Ok(StepResult::Skipped("no of-our-packages dependencies to install".into()));
}
- let sbx = ctx.sandbox()?;
+ let sbx = match sandbox_or_wait(ctx)? {
+ Some(s) => s,
+ None => return Ok(StepResult::Blocked(vec!["sandbox-pool".into()])),
+ };
for e in &lease {
let path = ctx.cfg.store_path(&e.digest);
// The hub hashes what it sends: store corruption is caught here, not
@@ -149,7 +152,10 @@ fn provision(ctx: &Ctx) -> Result<StepResult> {
argv.extend(lease.iter().map(|e| format!("blob:{}", e.digest)));
let out = sbx.run(&Cmd::new(argv), &mut |_| {})?;
if !out.success() {
- return Err(Error::fail_closed(format!(
+ // A refused `-U` is almost always an incomplete closure: the lease set
+ // cannot satisfy itself. Its own error class, because "the sandbox
+ // lied about its world" must not look like "the sandbox broke".
+ return Err(Error::world_mismatch(format!(
"{} -U refused the lease set: {}",
ctx.cfg.pacman_bin,
tail(&out.stderr)
@@ -176,7 +182,7 @@ fn provision(ctx: &Ctx) -> Result<StepResult> {
.collect();
for e in &lease {
if !installed.contains(&(e.name.clone(), e.version.clone())) {
- return Err(Error::fail_closed(format!(
+ return Err(Error::world_mismatch(format!(
"sandbox world is missing {}-{} after installing the lease set",
e.name, e.version
)));
@@ -191,6 +197,22 @@ fn provision(ctx: &Ctx) -> Result<StepResult> {
Ok(StepResult::Done(Some(crate::hash::canonical_json(&world)?)))
}
+/// Lease a sandbox for a step, or report that the pool cannot fit one right
+/// now. A full pool is not a broken build: the build blocks and waits, the
+/// same way it waits for a dependency it publishes (§10.4).
+fn sandbox_or_wait(
+ ctx: &Ctx,
+) -> Result<Option<std::sync::Arc<dyn crate::sandbox::Sandbox>>> {
+ match ctx.sandbox() {
+ Ok(s) => Ok(Some(s)),
+ Err(e) if e.is_pool_exhausted() => {
+ ctx.log_line(" blocked: no sandbox available in the pool");
+ Ok(None)
+ }
+ Err(e) => Err(e),
+ }
+}
+
/// One pinned entry of the lease manifest.
#[derive(Debug, Clone)]
struct LeasePkg {
@@ -307,6 +329,10 @@ fn pkgver(ctx: &Ctx) -> Result<StepResult> {
/// ingest signs hub-side.
fn build(ctx: &Ctx) -> Result<StepResult> {
let argv = vec![ctx.cfg.makepkg_bin.clone(), "-c".into(), "-f".into()];
+ let sbx = match sandbox_or_wait(ctx)? {
+ Some(s) => s,
+ None => return Ok(StepResult::Blocked(vec!["sandbox-pool".into()])),
+ };
// Capture the child's output into the build log regardless of outcome —
// the sandbox streams it here as it arrives, and the SSE tail reads the
// same file.
@@ -320,7 +346,6 @@ fn build(ctx: &Ctx) -> Result<StepResult> {
let _ = f.write_all(bytes);
}
};
- let sbx = ctx.sandbox()?;
let out = sbx.run(&Cmd::new(argv).in_dir(&ctx.srcdir), &mut on_log)?;
drop(on_log); // closes the log file before the outcome is recorded
if !out.success() {