Skip to content

Commit

Permalink
simplify more
Browse files Browse the repository at this point in the history
Signed-off-by: James Sturtevant <[email protected]>
  • Loading branch information
jsturtevant committed Aug 17, 2023
1 parent f6d1f45 commit 47612bf
Show file tree
Hide file tree
Showing 6 changed files with 17 additions and 28 deletions.
28 changes: 10 additions & 18 deletions crates/containerd-shim-wasm/src/sandbox/oci.rs
Original file line number Diff line number Diff line change
Expand Up @@ -105,20 +105,21 @@ pub fn setup_prestart_hooks(hooks: &Option<oci_spec::runtime::Hooks>) -> Result<
log::debug!("run_hooks arg0: {:?}, args: {:?}", arg0, args);

#[cfg(unix)]
hook_command.arg0(arg0).args(args);
{
hook_command.arg0(arg0).args(args);
}

#[cfg(windows)]
if !&hook.path().ends_with(arg0) {
log::debug!("Running with arg0 as different name than executable is not supported on Windows due to rust std library process implementation.");
} else {
{
if !&hook.path().ends_with(arg0) {
return Err(crate::sandbox::Error::InvalidArgument("Running with arg0 as different name than executable is not supported on Windows due to rust std library process implementation.".to_string()));
}

hook_command.args(args);
};
}
} else {
#[cfg(unix)]
hook_command.arg0(&hook.path().display().to_string());

#[cfg(windows)]
log::debug!("Running with hook path as process");
};

let envs: HashMap<String, String> = if let Some(env) = hook.env() {
Expand Down Expand Up @@ -149,16 +150,7 @@ pub fn setup_prestart_hooks(hooks: &Option<oci_spec::runtime::Hooks>) -> Result<
if e.kind() != ErrorKind::BrokenPipe {
// Not a broken pipe. The hook command may be waiting
// for us.
#[cfg(unix)]
{
let hook_process_pid = Pid::from_raw(hook_process.id() as i32);
let _ = signal::kill(hook_process_pid, signal::Signal::SIGKILL);
}

#[cfg(windows)]
{
let _ = hook_process.kill();
}
let _ = hook_process.kill();
}
}
}
Expand Down
4 changes: 0 additions & 4 deletions crates/containerd-shim-wasm/src/sandbox/shim.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
//! The shim is the entrypoint for the containerd shim API. It is responsible
//! for commmuincating with the containerd daemon and managing the lifecycle of
//! the container/sandbox.
//!
use std::collections::HashMap;
use std::env::current_dir;
Expand Down Expand Up @@ -866,13 +865,10 @@ impl<T: Instance + Send + Sync> Local<T> {
.as_ref()
.ok_or_else(|| Error::InvalidArgument("rootfs is not set in runtime spec".to_string()))?
.path();

let mut mkdir = DirBuilder::new();
mkdir.recursive(true);

#[cfg(unix)]
mkdir.mode(0o755);

if mkdir.create(rootfs).is_ok() { /* ignore */ }

let rootfs_mounts = req.rootfs().to_vec();
Expand Down
2 changes: 0 additions & 2 deletions crates/containerd-shim-wasmedge/src/executor.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
#![cfg(unix)]

use anyhow::Result;
use containerd_shim_wasm::sandbox::oci;
use nix::unistd::{dup, dup2};
Expand Down
5 changes: 4 additions & 1 deletion crates/containerd-shim-wasmedge/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
pub mod error;
pub mod executor;

pub mod instance;
pub mod oci_utils;

#[cfg(unix)]
pub mod executor;

#[cfg(unix)]
#[cfg(test)]
mod test {
Expand Down
2 changes: 0 additions & 2 deletions crates/containerd-shim-wasmtime/src/executor.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
#![cfg(unix)]

use nix::unistd::{dup, dup2};
use std::{fs::OpenOptions, os::fd::RawFd, path::PathBuf};

Expand Down
4 changes: 3 additions & 1 deletion crates/containerd-shim-wasmtime/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
pub mod error;
pub mod executor;
pub mod instance;
pub mod oci_wasmtime;

#[cfg(unix)]
pub mod executor;

0 comments on commit 47612bf

Please sign in to comment.