Skip to content

Commit 91acb60

Browse files
andrasbacsaiclaude
andcommitted
fix(builder): tolerate buildah storage-shutdown remount failure
Under coold's `systemd-run` sandbox, `buildah images` intermittently exits non-zero with Error: remount /var/lib/containers/storage/overlay, flags: 0x40000: invalid argument …even though it has already written the correct sha256: digest to stdout. The failure happens on storage shutdown, after the image has been committed by `bud`. Tolerate this: parse stdout for a valid sha256:... digest even when exit != 0, and only surface an error when stdout is missing / malformed. A warning is logged so the condition stays visible. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
1 parent d3d5590 commit 91acb60

1 file changed

Lines changed: 26 additions & 12 deletions

File tree

builder-core/src/static_build.rs

Lines changed: 26 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -77,13 +77,13 @@ pub async fn run(
7777
emit(sink, "build", "build complete", 80);
7878

7979
emit(sink, "store", "reading image digest", 90);
80-
// `buildah inspect` remounts the overlay store with MS_PRIVATE, which
81-
// fails inside the systemd-run sandbox coold wraps the builder in
82-
// (`remount /var/lib/containers/storage/overlay, flags: 0x40000:
83-
// invalid argument`). `buildah images` reads metadata without
84-
// remounting, so use it instead. `--storage-driver overlay` matches
85-
// the driver explicitly passed to `bud` so a non-default
86-
// `storage.conf` can't send us to a different store.
80+
// `buildah` under coold's systemd-run sandbox occasionally fails the
81+
// overlay store shutdown-remount with
82+
// `remount /var/lib/containers/storage/overlay, flags: 0x40000:
83+
// invalid argument` AFTER already writing the digest to stdout. The
84+
// image is correctly committed by `bud`, so tolerate a non-zero exit
85+
// when stdout still carries a well-formed sha256:... digest; only the
86+
// shutdown path misbehaves.
8787
let images_out = Command::new("buildah")
8888
.args([
8989
"--storage-driver",
@@ -96,13 +96,27 @@ pub async fn run(
9696
.output()
9797
.await
9898
.map_err(|e| err(500, "store", format!("buildah images spawn: {e}")))?;
99-
if !images_out.status.success() {
99+
let stdout = String::from_utf8_lossy(&images_out.stdout);
100+
let digest = stdout
101+
.lines()
102+
.find(|l| l.trim().starts_with("sha256:"))
103+
.map(|l| l.trim().to_owned())
104+
.unwrap_or_default();
105+
if digest.is_empty() {
100106
let stderr = String::from_utf8_lossy(&images_out.stderr).trim().to_owned();
101-
return Err(err(500, "store", format!("buildah images failed: {stderr}")));
107+
return Err(err(
108+
500,
109+
"store",
110+
format!(
111+
"buildah images: exit={:?}, no digest found; stderr: {stderr}",
112+
images_out.status.code()
113+
),
114+
));
102115
}
103-
let digest = String::from_utf8_lossy(&images_out.stdout).trim().to_owned();
104-
if digest.is_empty() || !digest.starts_with("sha256:") {
105-
return Err(err(500, "store", format!("unexpected digest format: {digest:?}")));
116+
if !images_out.status.success() {
117+
let stderr = String::from_utf8_lossy(&images_out.stderr).trim().to_owned();
118+
info!(%digest, stderr, status = ?images_out.status.code(),
119+
"buildah images exit non-zero but digest parsed from stdout; continuing");
106120
}
107121

108122
let registry_ref = format!("{}@{}", req.target_image, digest);

0 commit comments

Comments
 (0)