summaryrefslogtreecommitdiffstats
path: root/src/pipeline/mod.rs
diff options
context:
space:
mode:
authoraur-build <aur-build@localhost>2026-11-18 22:34:16 +0000
committeraur-build <aur-build@localhost>2026-11-18 22:34:16 +0000
commit632a08c8543f0db533efc7bfb6728b50a77ae3d8 (patch)
tree318fb224b15d09913e1111b8cdb80d9c578a8995 /src/pipeline/mod.rs
parent8835a0a86c82d922a2d674f3543c331dc9adb9e5 (diff)
downloadaur-build-632a08c8543f0db533efc7bfb6728b50a77ae3d8.tar.gz
aur-build-632a08c8543f0db533efc7bfb6728b50a77ae3d8.zip
sandbox: the seam between the pipeline and where build code runs
The step machine spawned its own subprocesses, which quietly made "build code runs on this machine, inside a devtools chroot, under §14's sudo rules" a pipeline fact rather than a deployment fact. Every build subprocess now goes through SandboxBackend: acquire a lease, run argv shaped commands (never a shell string), move content-addressed blobs, destroy. The loopback backend is today's behavior wearing the interface - same child_env shim protocol, same captured output - which is why the shim suite passes untouched: a step that cannot tell loopback from a remote sandbox is the property under test.
Diffstat (limited to 'src/pipeline/mod.rs')
-rw-r--r--src/pipeline/mod.rs23
1 files changed, 23 insertions, 0 deletions
diff --git a/src/pipeline/mod.rs b/src/pipeline/mod.rs
index bd37258..5e0a823 100644
--- a/src/pipeline/mod.rs
+++ b/src/pipeline/mod.rs
@@ -10,12 +10,15 @@ pub mod dispatch;
mod steps;
use std::path::PathBuf;
+use std::sync::Arc;
+use std::time::Duration;
use crate::config::Config;
use crate::db::{self, builds, Db, Pkgbase};
use crate::db::model::*;
use crate::db::SnapshotRow;
use crate::error::{Error, Result};
+use crate::sandbox::{Sandbox, SandboxBackend};
/// The approved source identity a build must reproduce.
///
@@ -120,6 +123,9 @@ pub struct Ctx {
pub log: PathBuf,
pub profile: String,
pub attempt: i64,
+ /// Where build code runs. Defaults to the loopback backend (§8, sandbox
+ /// seam); the pipeline itself never spawns a build subprocess directly.
+ pub backend: Arc<dyn SandboxBackend>,
}
impl Ctx {
@@ -165,9 +171,26 @@ impl Ctx {
log: cfg.build_log_path(build_id),
profile,
attempt,
+ backend: Arc::new(crate::sandbox::loopback::LoopbackBackend::new(cfg)),
})
}
+ /// Lease a sandbox for this build's profile. Today every step acquires and
+ /// releases around itself; a remote backend will hold one sandbox across
+ /// the sandbox-bearing steps of a build, and steps stay idempotent either
+ /// way (I5). The TTL is the lease window: a sandbox that outlives it is
+ /// assumed dead, which is exactly what the reaper already concludes about
+ /// an expired build lease.
+ pub fn sandbox(&self) -> Result<Arc<dyn Sandbox>> {
+ let spec = crate::sandbox::SandboxSpec {
+ profile: self.profile.clone(),
+ task: self.build.id.clone(),
+ ttl: Duration::from_secs(self.cfg.lease_secs.max(1) as u64),
+ disk_mb: self.cfg.min_free_disk_mb,
+ };
+ self.backend.acquire(&spec)
+ }
+
/// Append to the build log; the SSE tail reads this file (§12).
pub fn log_line(&self, line: &str) {
use std::io::Write;