Skip to content

Commit

Permalink
fix comments
Browse files Browse the repository at this point in the history
  • Loading branch information
MaloPolese committed Mar 21, 2023
1 parent 9a34c68 commit a476998
Show file tree
Hide file tree
Showing 8 changed files with 14 additions and 16 deletions.
1 change: 1 addition & 0 deletions Cargo.lock

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

1 change: 0 additions & 1 deletion riklet/src/core.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ pub enum RikletError {
}
type Result<T> = std::result::Result<T, RikletError>;

#[derive(Debug)]
pub struct Riklet {
config: Configuration,
hostname: String,
Expand Down
12 changes: 6 additions & 6 deletions riklet/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<()> {
Expand All @@ -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);
})
Expand Down
1 change: 0 additions & 1 deletion riklet/src/network/net.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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),
}
Expand Down
1 change: 0 additions & 1 deletion riklet/src/runtime/function_runtime.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion riklet/src/runtime/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ pub enum RuntimeError {
type Result<T> = std::result::Result<T, RuntimeError>;

#[async_trait]
pub trait Runtime: Send + Sync + Debug {
pub trait Runtime: Send + Sync {
async fn run(&mut self) -> Result<()>;
}

Expand Down
10 changes: 5 additions & 5 deletions riklet/src/runtime/network/function_network.rs
Original file line number Diff line number Diff line change
@@ -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::{
Expand All @@ -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,
Expand All @@ -22,6 +21,7 @@ pub struct FunctionRuntimeNetwork {
pub default_agent_port: u16,
pub workload_definition: WorkloadDefinition,
pub workload: InstanceScheduling,
pub tap: Option<Net>,
}

impl FunctionRuntimeNetwork {
Expand Down Expand Up @@ -56,21 +56,21 @@ impl FunctionRuntimeNetwork {
default_agent_port,
workload: workload.clone(),
workload_definition,
tap: None,
})
}
}

#[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)?;
Expand Down
2 changes: 1 addition & 1 deletion riklet/src/runtime/network/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ pub enum NetworkError {
type Result<T> = std::result::Result<T, NetworkError>;

#[async_trait]
pub trait RuntimeNetwork: Send + Sync + Debug {
pub trait RuntimeNetwork: Send + Sync {
async fn init(&self) -> Result<()>;

async fn destroy(&self) -> Result<()>;
Expand Down

0 comments on commit a476998

Please sign in to comment.