Skip to content

Commit

Permalink
[antlir2] Use disk for /tmp during rpm builds
Browse files Browse the repository at this point in the history
Summary:
See https://fb.workplace.com/groups/codetestingqa/posts/9412044228875340/ -- this is causing issues on Sandcastle for some RPMs. Opt to broadly move to disk as I expect the perf cost to be minimal (we're just dumping artifacts into here post-build, not really doing a significant amount of I/O).

I'll land this after the freeze.

Test Plan:
```
$ buck2 run mode/opt -c antlir.rc_targets=all //registry/builder/rpm/tests:fb-rpm-builder-test.base -- --no-publish
...
BUILD SUCCEEDED
{
  "linux": {
    "aarch64": {
      "primary": "/data/users/jtru/fbsource/buck-out/v2/gen/fbcode/7377c200435b9daa/registry/builder/rpm/tests/__fb-rpm-builder-test.base--rpm-stripped--aarch64__/fb-rpm-builder-test.base--rpm-stripped--aarch64.rpm",
      "debug": "/data/users/jtru/fbsource/buck-out/v2/gen/fbcode/7377c200435b9daa/registry/builder/rpm/tests/__fb-rpm-builder-test.base--rpm-debuginfo--aarch64__/fb-rpm-builder-test.base--rpm-debuginfo--aarch64.rpm"
    },
    "x86_64": {
      "primary": "/data/users/jtru/fbsource/buck-out/v2/gen/fbcode/fc0450a833f3ffe7/registry/builder/rpm/tests/__fb-rpm-builder-test.base--rpm-stripped--x86_64__/fb-rpm-builder-test.base--rpm-stripped--x86_64.rpm",
      "debug": "/data/users/jtru/fbsource/buck-out/v2/gen/fbcode/fc0450a833f3ffe7/registry/builder/rpm/tests/__fb-rpm-builder-test.base--rpm-debuginfo--x86_64__/fb-rpm-builder-test.base--rpm-debuginfo--x86_64.rpm"
    }
  }
}
```

Reviewed By: naveedgol

Differential Revision: D66508035

fbshipit-source-id: a10854694a03353e824440fc8778dfbce469cdbc
  • Loading branch information
justintrudell authored and facebook-github-bot committed Dec 5, 2024
1 parent 26fbfa2 commit e7b5d86
Showing 1 changed file with 7 additions and 9 deletions.
16 changes: 7 additions & 9 deletions antlir/antlir2/antlir2_packager/src/rpm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ use nix::unistd::Group;
use nix::unistd::Uid;
use nix::unistd::User;
use serde::Deserialize;
use tempfile::NamedTempFile;

use crate::run_cmd;
use crate::BuildAppliance;
Expand Down Expand Up @@ -330,18 +329,18 @@ AutoProv: {autoprov}
spec.push_str(extra_file);
spec.push('\n');
}
let mut rpm_spec_file =
NamedTempFile::new().context("failed to create tempfile for rpm spec")?;
rpm_spec_file
.write(spec.as_bytes())
.context("while writing rpm spec file")?;

let output_dir = tempfile::tempdir().context("while creating temp dir for rpm output")?;

// create the arch-specific output dir explicitly so that it'll be
// owned by the build user on the host, not root
std::fs::create_dir(output_dir.path().join(arch)).context("while creating output dir")?;

// Note we use a standard dir for /tmp rather than tmpfs because we write full
// build artifacts here, and can thus easily run out of ramdisk
let tmp = tempfile::tempdir().context("while creating temp dir for rpm build")?;
let rpm_spec_file = tmp.path().join("rpmspec");
std::fs::write(rpm_spec_file, spec.as_bytes()).context("while writing rpm spec file")?;

let mut isol_context = IsolationContext::builder(self.build_appliance.path());
isol_context
.ephemeral(false)
Expand All @@ -353,10 +352,9 @@ AutoProv: {autoprov}
std::env::current_dir()?,
))
.working_directory(Path::new("/__antlir2__/working_directory"))
.inputs((Path::new("/tmp/rpmspec"), rpm_spec_file.path()))
.inputs((Path::new("/__antlir2__/root"), layer))
.outputs((Path::new("/__antlir2__/out"), output_dir.path()))
.tmpfs(Path::new("/tmp"))
.outputs((Path::new("/tmp"), tmp.path()))
.tmpfs(Path::new("/dev"))
.inputs(Path::new("/dev/null"));
#[cfg(facebook)]
Expand Down

0 comments on commit e7b5d86

Please sign in to comment.