-
Notifications
You must be signed in to change notification settings - Fork 90
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
wasm: add wasmEdge container process to cgroup #87
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -20,7 +20,7 @@ use tokio::fs::read; | |
use wasmtime::{Config, Engine, Extern, Linker, Module, Store, StoreLimits, StoreLimitsBuilder}; | ||
use wasmtime_wasi::{tokio::WasiCtxBuilder, WasiCtx}; | ||
|
||
use crate::utils; | ||
use crate::utils::{get_args, get_kv_envs, get_memory_limit, get_rootfs}; | ||
|
||
pub type ExecProcess = ProcessTemplate<WasmtimeExecLifecycle>; | ||
pub type InitProcess = ProcessTemplate<WasmtimeInitLifecycle>; | ||
|
@@ -59,16 +59,12 @@ impl ContainerFactory<WasmtimeContainer> for WasmtimeContainerFactory { | |
let mut spec: Spec = read_spec(req.bundle()).await?; | ||
spec.canonicalize_rootfs(req.bundle()) | ||
.map_err(|e| Error::InvalidArgument(format!("could not canonicalize rootfs: {e}")))?; | ||
let rootfs = spec | ||
.root() | ||
.as_ref() | ||
.ok_or(Error::InvalidArgument( | ||
"rootfs is not set in runtime spec".to_string(), | ||
))? | ||
.path(); | ||
mkdir(rootfs, 0o711).await?; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. why is this mkdir removed? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Sorry, will update later |
||
let rootfs = get_rootfs(&spec).ok_or_else(|| { | ||
Error::InvalidArgument("rootfs is not set in runtime spec".to_string()) | ||
})?; | ||
mkdir(&rootfs, 0o711).await?; | ||
for m in req.rootfs() { | ||
mount_rootfs(m, rootfs.as_path()).await? | ||
mount_rootfs(m, &rootfs).await? | ||
} | ||
let stdio = Stdio::new(req.stdin(), req.stdout(), req.stderr(), req.terminal); | ||
let exit_signal = Arc::new(Default::default()); | ||
|
@@ -115,8 +111,8 @@ impl WasmtimeInitLifecycle { | |
#[async_trait::async_trait] | ||
impl ProcessLifecycle<InitProcess> for WasmtimeInitLifecycle { | ||
async fn start(&self, p: &mut InitProcess) -> containerd_shim::Result<()> { | ||
let args = utils::get_args(&self.spec); | ||
let envs = utils::get_kv_envs(&self.spec); | ||
let args = get_args(&self.spec); | ||
let envs = get_kv_envs(&self.spec); | ||
let root = self | ||
.spec | ||
.root() | ||
|
@@ -165,7 +161,7 @@ impl ProcessLifecycle<InitProcess> for WasmtimeInitLifecycle { | |
let ctx = builder.build(); | ||
|
||
let mut limits_builder = StoreLimitsBuilder::new(); | ||
if let Some(memory_size) = utils::get_memory_limit(&self.spec).map(|x| x as usize) { | ||
if let Some(memory_size) = get_memory_limit(&self.spec).map(|x| x as usize) { | ||
limits_builder = limits_builder.memory_size(memory_size); | ||
} | ||
let limiter = limits_builder.build(); | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Exec in wasm container is still not supported, so should return
Err
here.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done