Skip to content

Commit

Permalink
[chore] remove unused engine field
Browse files Browse the repository at this point in the history
Signed-off-by: Jorge Prendes <jorge.prendes@gmail.com>
  • Loading branch information
jprendes committed Feb 28, 2025
1 parent 3a72785 commit e2af68f
Show file tree
Hide file tree
Showing 7 changed files with 9 additions and 43 deletions.
2 changes: 0 additions & 2 deletions crates/containerd-shim-wasm/src/sandbox/cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,6 @@ pub fn shim_main<'a, I>(
config: Option<Config>,
) where
I: 'static + Instance + Sync + Send,
I::Engine: Default,
{
#[cfg(unix)]
zygote::Zygote::init();
Expand Down Expand Up @@ -203,7 +202,6 @@ fn shim_main_inner<'a, I>(
config: Option<Config>,
) where
I: 'static + Instance + Sync + Send,
I::Engine: Default,
{
#[cfg(feature = "opentelemetry")]
{
Expand Down
3 changes: 0 additions & 3 deletions crates/containerd-shim-wasm/src/sandbox/instance.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,6 @@ pub struct InstanceConfig {
/// This trait requires that any type implementing it is `'static`, similar to `std::any::Any`.
/// This means that the type cannot contain a non-`'static` reference.
pub trait Instance: 'static {
/// The WASI engine type
type Engine: Send + Sync + Clone;

/// Create a new instance
fn new(id: String, cfg: &InstanceConfig) -> Result<Self, Error>
where
Expand Down
16 changes: 4 additions & 12 deletions crates/containerd-shim-wasm/src/sandbox/shim/cli.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
use std::env::current_dir;
use std::fmt::Debug;
use std::marker::PhantomData;
use std::sync::Arc;

use chrono::Utc;
Expand All @@ -16,17 +17,16 @@ use crate::sandbox::shim::local::Local;

/// Cli implements the containerd-shim cli interface using `Local<T>` as the task service.
pub struct Cli<T: Instance + Sync + Send> {
engine: T::Engine,
namespace: String,
containerd_address: String,
exit: Arc<ExitSignal>,
_id: String,
_phantom: PhantomData<T>,
}

impl<I> Debug for Cli<I>
where
I: Instance + Sync + Send,
<I as Instance>::Engine: Default,
{
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
write!(
Expand All @@ -40,18 +40,17 @@ where
impl<I> shim::Shim for Cli<I>
where
I: Instance + Sync + Send,
<I as Instance>::Engine: Default,
{
type T = Local<I>;

#[cfg_attr(feature = "tracing", tracing::instrument(level = "Info"))]
fn new(_runtime_id: &str, args: &Flags, _config: &mut shim::Config) -> Self {
Cli {
engine: Default::default(),
namespace: args.namespace.to_string(),
containerd_address: args.address.clone(),
exit: Arc::default(),
_id: args.id.to_string(),
_phantom: PhantomData,
}
}

Expand Down Expand Up @@ -88,14 +87,7 @@ where
fn create_task_service(&self, publisher: RemotePublisher) -> Self::T {
let events = RemoteEventSender::new(&self.namespace, publisher);
let exit = self.exit.clone();
let engine = self.engine.clone();
Local::<I>::new(
engine,
events,
exit,
&self.namespace,
&self.containerd_address,
)
Local::<I>::new(events, exit, &self.namespace, &self.containerd_address)
}

#[cfg_attr(feature = "tracing", tracing::instrument(level = "Info"))]
Expand Down
5 changes: 1 addition & 4 deletions crates/containerd-shim-wasm/src/sandbox/shim/local.rs
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,6 @@ type LocalInstances<T> = RwLock<HashMap<String, Arc<InstanceData<T>>>>;
/// Local implements the Task service for a containerd shim.
/// It defers all task operations to the `Instance` implementation.
pub struct Local<T: Instance + Send + Sync, E: EventSender = RemoteEventSender> {
pub engine: T::Engine,
pub(super) instances: LocalInstances<T>,
events: E,
exit: Arc<ExitSignal>,
Expand All @@ -99,10 +98,9 @@ impl<T: Instance + Send + Sync, E: EventSender> Local<T, E> {
/// Creates a new local task service.
#[cfg_attr(
feature = "tracing",
tracing::instrument(skip(engine, events, exit), level = "Debug")
tracing::instrument(skip(events, exit), level = "Debug")
)]
pub fn new(
engine: T::Engine,
events: E,
exit: Arc<ExitSignal>,
namespace: impl AsRef<str> + std::fmt::Debug,
Expand All @@ -112,7 +110,6 @@ impl<T: Instance + Send + Sync, E: EventSender> Local<T, E> {
let namespace = namespace.as_ref().to_string();
let containerd_address = containerd_address.as_ref().to_string();
Self {
engine,
instances,
events,
exit,
Expand Down
4 changes: 0 additions & 4 deletions crates/containerd-shim-wasm/src/sandbox/shim/local/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ pub struct InstanceStub {
}

impl Instance for InstanceStub {
type Engine = ();
fn new(_id: String, _cfg: &InstanceConfig) -> Result<Self, Error> {
Ok(InstanceStub {
exit_code: WaitableCell::new(),
Expand Down Expand Up @@ -106,7 +105,6 @@ fn test_delete_after_create() {

let (tx, _rx) = channel();
let local = Arc::new(Local::<InstanceStub, _>::new(
(),
tx,
Arc::new(ExitSignal::default()),
"test_namespace",
Expand Down Expand Up @@ -137,7 +135,6 @@ fn test_cri_task() -> Result<()> {
let (etx, _erx) = channel();
let exit_signal = Arc::new(ExitSignal::default());
let local = Arc::new(Local::<InstanceStub, _>::new(
(),
etx,
exit_signal,
"test_namespace",
Expand Down Expand Up @@ -307,7 +304,6 @@ fn test_task_lifecycle() -> Result<()> {
let (etx, _erx) = channel(); // TODO: check events
let exit_signal = Arc::new(ExitSignal::default());
let local = Arc::new(Local::<InstanceStub, _>::new(
(),
etx,
exit_signal,
"test_namespace",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,6 @@ pub struct Instance<E: Engine> {
}

impl<E: Engine + Default> SandboxInstance for Instance<E> {
type Engine = E;

#[cfg_attr(feature = "tracing", tracing::instrument(level = "Info"))]
fn new(id: String, cfg: &InstanceConfig) -> Result<Self, SandboxError> {
// check if container is OCI image with wasm layers and attempt to read the module
Expand Down
20 changes: 4 additions & 16 deletions crates/containerd-shim-wasm/src/testing.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,29 +25,20 @@ use crate::sandbox::{Instance, InstanceConfig};
pub const TEST_NAMESPACE: &str = "runwasi-test";
pub const SIGKILL: u32 = 9;

pub struct WasiTestBuilder<WasiInstance: Instance>
where
WasiInstance::Engine: Default + Send + Sync + Clone,
{
pub struct WasiTestBuilder<WasiInstance: Instance> {
container_name: String,
start_fn: String,
namespaces: Vec<LinuxNamespace>,
tempdir: tempfile::TempDir,
_phantom: PhantomData<WasiInstance>,
}

pub struct WasiTest<WasiInstance: Instance>
where
WasiInstance::Engine: Default + Send + Sync + Clone,
{
pub struct WasiTest<WasiInstance: Instance> {
instance: WasiInstance,
tempdir: tempfile::TempDir,
}

impl<WasiInstance: Instance> WasiTestBuilder<WasiInstance>
where
WasiInstance::Engine: Default + Send + Sync + Clone,
{
impl<WasiInstance: Instance> WasiTestBuilder<WasiInstance> {
pub fn new() -> Result<Self> {
zygote::Zygote::init();

Expand Down Expand Up @@ -230,10 +221,7 @@ where
}
}

impl<WasiInstance: Instance> WasiTest<WasiInstance>
where
WasiInstance::Engine: Default + Send + Sync + Clone,
{
impl<WasiInstance: Instance> WasiTest<WasiInstance> {
pub fn builder() -> Result<WasiTestBuilder<WasiInstance>> {
WasiTestBuilder::new()
}
Expand Down

0 comments on commit e2af68f

Please sign in to comment.