Skip to content

Commit

Permalink
Feature/create workspace dir (#15)
Browse files Browse the repository at this point in the history
* build: update MIA version and use new 9p mount constructor

* build: add step for creating workspace directory

* fix: create workspace directory with fs api

---------

Co-authored-by: Tino Rusch <[email protected]>
  • Loading branch information
aleasims and trusch authored Nov 1, 2024
1 parent ec8b470 commit 06356a0
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 12 deletions.
6 changes: 3 additions & 3 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@ tokio = { version = "1", features = ["full"] }
toml = "0.8.19"

[target.'cfg(target_os = "linux")'.dependencies]
mia-rt-config = { git = "https://github.com/gevulotnetwork/mia.git", tag = "v0.2.0" }
mia-installer = { git = "https://github.com/gevulotnetwork/mia.git", tag = "v0.2.0" }
mia-rt-config = { git = "https://github.com/gevulotnetwork/mia.git", tag = "v0.2.1" }
mia-installer = { git = "https://github.com/gevulotnetwork/mia.git", tag = "v0.2.1" }

anyhow = "1"
log = "0.4.22"
Expand Down
24 changes: 17 additions & 7 deletions src/builders/skopeo_builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,10 @@ impl ImageBuilder for SkopeoSyslinuxBuilder {
print(&format!("✅\n"))?;
}

print("Creating workspace directory...")?;
Self::create_workspace()?;
print("✅\n")?;

if let Some(kernel_path) = &options.kernel_file {
if options.nvidia_drivers {
print("WARNING: Installing NVIDIA drivers for precompiled kernel is not supported yet!")?;
Expand Down Expand Up @@ -460,6 +464,15 @@ impl SkopeoSyslinuxBuilder {
.context("Failed to install rootfs from built container")
}

/// Create `/workspace` directory in the VM, which will be used as output mountpoint.
fn create_workspace() -> Result<()> {
let ws_path = env::temp_dir().join("mnt").join("workspace");
if !ws_path.exists() {
fs::create_dir_all(&ws_path).context("Failed to create workspace directory")?;
}
Ok(())
}

// Install the Linux kernel
fn install_kernel(
version: &str,
Expand Down Expand Up @@ -588,13 +601,10 @@ impl SkopeoSyslinuxBuilder {
.collect::<Vec<_>>();

let follow_config = if gevulot_rt_config {
mounts.push(mia_rt_config::Mount {
source: "gevulot-rt-config".to_string(),
target: "/mnt/gevulot-rt-config".to_string(),
fstype: Some("9p".to_string()),
flags: None,
data: Some("trans=virtio,version=9p2000.L".to_string()),
});
mounts.push(mia_rt_config::Mount::virtio9p(
"gevulot-rt-config".to_string(),
"/mnt/gevulot-rt-config".to_string(),
));
// NOTE: Worker node will mount runtime config file to tag `gevulot-rt-config`.
// This is a convention between VM and node we have now.
Some("/mnt/gevulot-rt-config/config.yaml".to_string())
Expand Down

0 comments on commit 06356a0

Please sign in to comment.