Skip to content

Commit

Permalink
Review feedback and fmt
Browse files Browse the repository at this point in the history
  • Loading branch information
Furisto committed Jul 6, 2021
1 parent 0eaa906 commit e76360b
Show file tree
Hide file tree
Showing 10 changed files with 38 additions and 35 deletions.
2 changes: 1 addition & 1 deletion src/capabilities.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use crate::command::{Syscall};
use crate::command::Syscall;
use caps::*;

use anyhow::Result;
Expand Down
7 changes: 2 additions & 5 deletions src/cgroups/v1/pids.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use std::path::{Path};
use std::path::Path;

use anyhow::Result;

Expand All @@ -10,10 +10,7 @@ pub struct Pids {}
impl Controller for Pids {
type Resource = LinuxPids;

fn apply(
linux_resources: &LinuxResources,
cgroup_root: &Path,
) -> Result<()> {
fn apply(linux_resources: &LinuxResources, cgroup_root: &Path) -> Result<()> {
log::debug!("Apply pids cgroup config");

if let Some(pids) = &linux_resources.pids {
Expand Down
2 changes: 1 addition & 1 deletion src/cgroups/v1/util.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ use std::{collections::HashMap, path::PathBuf};
use anyhow::{anyhow, Result};
use procfs::process::Process;

use super::{ControllerType, controller_type::CONTROLLERS};
use super::{controller_type::CONTROLLERS, ControllerType};

pub fn list_subsystem_mount_points() -> Result<HashMap<ControllerType, PathBuf>> {
let mut mount_paths = HashMap::with_capacity(CONTROLLERS.len());
Expand Down
14 changes: 8 additions & 6 deletions src/cgroups/v2/systemd_manager.rs
Original file line number Diff line number Diff line change
Expand Up @@ -261,9 +261,10 @@ mod tests {

#[test]
fn get_cgroups_path_works_with_a_complex_slice() -> Result<()> {
let cgroups_path =
SystemDCGroupManager::destructure_cgroups_path(PathBuf::from("test-a-b.slice:docker:foo"))
.expect("");
let cgroups_path = SystemDCGroupManager::destructure_cgroups_path(PathBuf::from(
"test-a-b.slice:docker:foo",
))
.expect("");

assert_eq!(
SystemDCGroupManager::construct_cgroups_path(cgroups_path)?,
Expand All @@ -275,9 +276,10 @@ mod tests {

#[test]
fn get_cgroups_path_works_with_a_simple_slice() -> Result<()> {
let cgroups_path =
SystemDCGroupManager::destructure_cgroups_path(PathBuf::from("machine.slice:libpod:foo"))
.expect("");
let cgroups_path = SystemDCGroupManager::destructure_cgroups_path(PathBuf::from(
"machine.slice:libpod:foo",
))
.expect("");

assert_eq!(
SystemDCGroupManager::construct_cgroups_path(cgroups_path)?,
Expand Down
2 changes: 1 addition & 1 deletion src/command/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@
//! This provides a uniform interface for rest of Youki
//! to call syscalls required for container management

pub mod linux;
#[allow(clippy::module_inception)]
pub mod syscall;
pub mod linux;
pub mod test;

pub use syscall::Syscall;
19 changes: 9 additions & 10 deletions src/container/builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@ pub struct ContainerBuilder {
pub(super) console_socket: Option<PathBuf>,
}

/// Builder that can be used to configure the common properties of
/// either a init or a tenant container
///
/// Builder that can be used to configure the common properties of
/// either a init or a tenant container
///
/// # Example
///
/// ```no_run
Expand Down Expand Up @@ -54,7 +54,7 @@ impl ContainerBuilder {

/// Transforms this builder into a tenant builder
/// # Example
///
///
/// ```no_run
/// # use youki::container::builder::ContainerBuilder;
///
Expand All @@ -70,7 +70,7 @@ impl ContainerBuilder {

/// Transforms this builder into an init builder
/// # Example
///
///
/// ```no_run
/// # use youki::container::builder::ContainerBuilder;
///
Expand All @@ -86,7 +86,7 @@ impl ContainerBuilder {

/// Sets the root path which will be used to store the container state
/// # Example
///
///
/// ```no_run
/// # use youki::container::builder::ContainerBuilder;
///
Expand All @@ -101,7 +101,7 @@ impl ContainerBuilder {
/// Sets the pid file which will be used to write the pid of the container
/// process
/// # Example
///
///
/// ```no_run
/// # use youki::container::builder::ContainerBuilder;
///
Expand All @@ -113,10 +113,10 @@ impl ContainerBuilder {
self
}

/// Sets the console socket, which will be used to send the file descriptor
/// Sets the console socket, which will be used to send the file descriptor
/// of the pseudoterminal
/// # Example
///
///
/// ```no_run
/// # use youki::container::builder::ContainerBuilder;
///
Expand All @@ -128,4 +128,3 @@ impl ContainerBuilder {
self
}
}

2 changes: 1 addition & 1 deletion src/container/init_builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ pub struct InitContainerBuilder {
}

impl InitContainerBuilder {
/// Generates the base configuration for a new container from which
/// Generates the base configuration for a new container from which
/// configuration methods can be chained
pub(super) fn new(builder: ContainerBuilder, bundle: PathBuf) -> Self {
Self {
Expand Down
14 changes: 7 additions & 7 deletions src/process/fork.rs
Original file line number Diff line number Diff line change
Expand Up @@ -74,14 +74,14 @@ pub fn fork_first<P: AsRef<Path>>(
}

if let Some(container) = container {
// update status and pid of the container process
container
.update_status(ContainerStatus::Created)
.set_creator(nix::unistd::geteuid().as_raw())
.set_pid(init_pid)
.save()?;
// update status and pid of the container process
container
.update_status(ContainerStatus::Created)
.set_creator(nix::unistd::geteuid().as_raw())
.set_pid(init_pid)
.save()?;
}

// if file to write the pid to is specified, write pid of the child
if let Some(pid_file) = pid_file {
fs::write(&pid_file, format!("{}", child))?;
Expand Down
9 changes: 7 additions & 2 deletions src/process/init.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,14 @@ use std::{io::Write, path::PathBuf};

use anyhow::Result;
use mio::unix::pipe::Sender;
use nix::{sched, unistd::{Gid, Uid}};
use nix::{
sched,
unistd::{Gid, Uid},
};

use crate::{capabilities, command::Syscall, namespaces::Namespaces, process::message::Message, rootfs};
use crate::{
capabilities, command::Syscall, namespaces::Namespaces, process::message::Message, rootfs,
};

/// Contains sending end for pipe for the child process
pub struct InitProcess {
Expand Down
2 changes: 1 addition & 1 deletion src/process/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ mod child;
mod init;
mod parent;

pub use init::{InitProcess, setup_init_process};
pub use init::{setup_init_process, InitProcess};

/// Used to describe type of process after fork.
/// Parent and child processes mean the same thing as in a normal fork call
Expand Down

0 comments on commit e76360b

Please sign in to comment.