Skip to content

Commit e325080

Browse files
mangelajoclaude
andcommitted
Use rpm2cpio for u-boot extraction to avoid 572MB memory spike
rpmfile decompresses the entire zstd CPIO payload (572MB) into memory to extract a 1.6MB file. On 4Gi VMs running parallel tests this triggers the OOM killer. Use rpm2cpio + cpio on Linux which streams without buffering; fall back to rpmfile on macOS. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent ba70ce5 commit e325080

1 file changed

Lines changed: 14 additions & 5 deletions

File tree

  • python/packages/jumpstarter-driver-uboot/jumpstarter_driver_uboot

python/packages/jumpstarter-driver-uboot/jumpstarter_driver_uboot/driver_test.py

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
import os
22
import platform
3+
import shutil
4+
import subprocess
35

46
import pytest
57
import requests
@@ -35,12 +37,19 @@ def uboot_image(tmpdir_factory):
3537
pytest.fail(f"Failed to download u-boot RPM: {e}")
3638

3739
print("Extracting u-boot.bin from RPM...")
38-
with rpmfile.open(rpm_path) as rpm:
39-
fd = rpm.extractfile("./usr/share/uboot/qemu_arm64/u-boot.bin")
40-
with bin_path.open("wb") as f:
41-
f.write(fd.read())
40+
if shutil.which("rpm2cpio") and shutil.which("cpio"):
41+
subprocess.run(
42+
f"rpm2cpio {rpm_path} | cpio -idm --quiet ./usr/share/uboot/qemu_arm64/u-boot.bin",
43+
shell=True, cwd=str(tmp_path), check=True,
44+
)
45+
extracted = tmp_path / "usr" / "share" / "uboot" / "qemu_arm64" / "u-boot.bin"
46+
extracted.rename(bin_path)
47+
else:
48+
with rpmfile.open(rpm_path) as rpm:
49+
fd = rpm.extractfile("./usr/share/uboot/qemu_arm64/u-boot.bin")
50+
with bin_path.open("wb") as f:
51+
f.write(fd.read())
4252
print(f"Extracted u-boot.bin ({bin_path.stat().st_size} bytes)")
43-
print("Starting QEMU test...")
4453

4554
yield bin_path
4655

0 commit comments

Comments
 (0)