diff options
| author | aur-build <aur-build@localhost> | 2026-11-18 08:47:27 +0000 |
|---|---|---|
| committer | aur-build <aur-build@localhost> | 2026-11-18 08:47:27 +0000 |
| commit | 2c5a660213ae5f9f6f12d9787c5195e2c2127e6d (patch) | |
| tree | 602453277de22abf2dabc2501f2f69f2afea6e0e /src/shims | |
| parent | e27e90aa82b6c878e34b94a6fa238836f497b1c3 (diff) | |
| download | aur-build-2c5a660213ae5f9f6f12d9787c5195e2c2127e6d.tar.gz aur-build-2c5a660213ae5f9f6f12d9787c5195e2c2127e6d.zip | |
pipeline: a real process kill, and the failure state the UI must show (§8.4, I5)
The crash-resume invariant was only ever simulated before: an in-process fault
hook returns an error, and an error can be caught, unwound and cleaned up by
accident. So the shims gained AUR_SHIM_KILL_PARENT — the named tool SIGKILLs
the process running the pipeline, mid-step, with no Drop and no atexit.
The test spawns the real aur-build binary, watches it die of SIGKILL inside
the build step, and then asserts the things that matter:
- the database is intact, because no transaction ever spans a build step
- the completed steps are checkpointed succeeded and the running one is
recorded running
- after the lease expires the reaper requeues it and marks the step
interrupted
- resuming publishes exactly one release, and the shim invocation log proves
mkarchroot ran once, makechrootpkg twice (crash + resume, not twice per
attempt) and repo-add once
**This found a real bug.** reap_expired only matched state='leased', but a
worker sets state='running' the moment it starts a step, so a process that
dies mid-step leaves a running row — and every real crash would have been
stranded forever. The reaper now reaps leased and running.
Also §8.4's other half, which was a comment rather than a feature: a failed
build must not leave the old version looking healthy. db::approved_but_unbuilt
finds approvals whose build failed and never published, and Attention and the
package page now say 'v2 approved, build failed, index still serving v1' with
a link to the log. Retrying is an explicit, audited POST, not something the
system does to itself.
Cancellation is asserted to be cooperative at a step boundary: a cancelled
build runs no steps, publishes nothing, and is not counted as a failure.
Diffstat (limited to 'src/shims')
| -rw-r--r-- | src/shims/mod.rs | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/src/shims/mod.rs b/src/shims/mod.rs index 32ae7c9..5560aa3 100644 --- a/src/shims/mod.rs +++ b/src/shims/mod.rs @@ -147,6 +147,24 @@ pub fn record(tool: &str, args: &[String]) { } } +/// Test hook: kill the process that invoked us, mid-step, with a signal it +/// cannot catch. This is how the crash-resume invariant (I5) is tested for real: +/// the pipeline process dies while a step is running, with no chance to clean +/// up, and the next process must pick up from the checkpoints. +fn kill_parent_if_asked(tool: &str) { + let want = std::env::var("AUR_SHIM_KILL_PARENT").unwrap_or_default(); + if want == tool { + // Flush the invocation log first (record() already closed the file), + // then murder the parent. No cleanup, no unwinding, no atexit. + unsafe { + libc::kill(libc::getppid(), libc::SIGKILL); + } + // If the kill somehow did not land, do not let the step complete — that + // would make the test silently test nothing. + std::process::exit(137); + } +} + /// True when the harness asked this tool to fail. fn forced_fail(tool: &str) -> bool { std::env::var("AUR_SHIM_FAIL").map(|v| v == tool).unwrap_or(false) @@ -182,6 +200,7 @@ pub fn called_with(dir: &Path, tool: &str, needle: &str) -> usize { pub fn run(tool: &str) -> i32 { let args: Vec<String> = std::env::args().skip(1).collect(); record(tool, &args); + kill_parent_if_asked(tool); let m = manifest(); let r = match tool { "mkarchroot" => mkarchroot(&args), |
