diff --git a/Cargo.lock b/Cargo.lock index 340c9581..2e60e755 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2592,6 +2592,7 @@ dependencies = [ "iptables", "libc", "lz4", + "netlink-packet-route", "nix 0.21.0", "node_metrics", "oci", diff --git a/riklet/src/core.rs b/riklet/src/core.rs index 3a304b5a..389b3ff3 100644 --- a/riklet/src/core.rs +++ b/riklet/src/core.rs @@ -35,7 +35,6 @@ pub enum RikletError { } type Result = std::result::Result; -#[derive(Debug)] pub struct Riklet { config: Configuration, hostname: String, diff --git a/riklet/src/main.rs b/riklet/src/main.rs index c7ae4e04..37c5ad31 100644 --- a/riklet/src/main.rs +++ b/riklet/src/main.rs @@ -13,7 +13,7 @@ use crate::core::Riklet; use crate::utils::init_logger; use anyhow::Result; -use tracing::{event, Level}; +use tracing::error; #[tokio::main] async fn main() -> Result<()> { @@ -23,16 +23,16 @@ async fn main() -> Result<()> { // test_instrument(); // If the process doesn't have root privileges, exit and display error. if !nix::unistd::Uid::effective().is_root() { - event!(Level::ERROR, "Riklet must run with root privileges."); + error!("Riklet must run with root privileges."); std::process::exit(1); } Riklet::new() .await - .unwrap_or_else(|_| { - event!( - Level::ERROR, - "An error occured during the bootstraping process of the Riklet." + .unwrap_or_else(|e| { + error!( + "An error occured during the bootstraping process of the Riklet. {}", + e ); std::process::exit(2); }) diff --git a/riklet/src/network/net.rs b/riklet/src/network/net.rs index c49e309e..6ce94fff 100644 --- a/riklet/src/network/net.rs +++ b/riklet/src/network/net.rs @@ -74,7 +74,6 @@ pub enum NetworkInterfaceError { #[error("Interface name is invalid, expected to be less than 15 characters")] InvalidInterfaceName, } - pub enum NetworkInterface { TapInterface(VirtioNet), } diff --git a/riklet/src/runtime/function_runtime.rs b/riklet/src/runtime/function_runtime.rs index c3e77046..08d8eaf6 100644 --- a/riklet/src/runtime/function_runtime.rs +++ b/riklet/src/runtime/function_runtime.rs @@ -22,7 +22,6 @@ use tracing::{event, Level}; use super::{network::function_network::FunctionRuntimeNetwork, Runtime, RuntimeManager}; -#[derive(Debug)] struct FunctionRuntime { function_config: FnConfiguration, file_path: String, diff --git a/riklet/src/runtime/mod.rs b/riklet/src/runtime/mod.rs index a651763f..77cf2433 100644 --- a/riklet/src/runtime/mod.rs +++ b/riklet/src/runtime/mod.rs @@ -40,7 +40,7 @@ pub enum RuntimeError { type Result = std::result::Result; #[async_trait] -pub trait Runtime: Send + Sync + Debug { +pub trait Runtime: Send + Sync { async fn run(&mut self) -> Result<()>; } diff --git a/riklet/src/runtime/network/function_network.rs b/riklet/src/runtime/network/function_network.rs index 15918622..b494062b 100644 --- a/riklet/src/runtime/network/function_network.rs +++ b/riklet/src/runtime/network/function_network.rs @@ -1,8 +1,8 @@ use async_trait::async_trait; use proto::worker::InstanceScheduling; -use std::fmt::Debug; use std::net::Ipv4Addr; use tracing::debug; +use tracing::log::info; use crate::network::net::{Net, NetworkInterfaceConfig}; use crate::{ @@ -13,7 +13,6 @@ use crate::{ use super::{NetworkError, Result, RuntimeNetwork, IP_ALLOCATOR}; -#[derive(Debug, Clone)] pub struct FunctionRuntimeNetwork { pub mask_long: String, pub firecracker_ip: Ipv4Addr, @@ -22,6 +21,7 @@ pub struct FunctionRuntimeNetwork { pub default_agent_port: u16, pub workload_definition: WorkloadDefinition, pub workload: InstanceScheduling, + pub tap: Option, } impl FunctionRuntimeNetwork { @@ -56,6 +56,7 @@ impl FunctionRuntimeNetwork { default_agent_port, workload: workload.clone(), workload_definition, + tap: None, }) } } @@ -63,14 +64,13 @@ impl FunctionRuntimeNetwork { #[async_trait] impl RuntimeNetwork for FunctionRuntimeNetwork { async fn init(&self) -> Result<()> { - println!("Function network initialized"); + info!("Function network initialized"); // Port forward microvm on the host let exposed_port = self.workload_definition.get_expected_port(); - let config = NetworkInterfaceConfig::new( + let config = NetworkInterfaceConfig::new_with_random_name( self.workload.instance_id.clone(), - self.workload_definition.name.clone(), self.tap_ip, ) .map_err(NetworkError::NetworkInterfaceError)?; diff --git a/riklet/src/runtime/network/mod.rs b/riklet/src/runtime/network/mod.rs index 5f4bcacb..be2f12d2 100644 --- a/riklet/src/runtime/network/mod.rs +++ b/riklet/src/runtime/network/mod.rs @@ -35,7 +35,7 @@ pub enum NetworkError { type Result = std::result::Result; #[async_trait] -pub trait RuntimeNetwork: Send + Sync + Debug { +pub trait RuntimeNetwork: Send + Sync { async fn init(&self) -> Result<()>; async fn destroy(&self) -> Result<()>;