From b7d056055d5ffe8a620e72340bdea22b6b4bff0b Mon Sep 17 00:00:00 2001 From: Furisto <24721048+Furisto@users.noreply.github.com> Date: Sat, 17 Jul 2021 15:55:38 +0200 Subject: [PATCH] Add comments --- src/container/builder.rs | 10 ++++++---- src/container/builder_impl.rs | 14 +++++++++++++- src/container/init_builder.rs | 1 - src/container/mod.rs | 5 +++++ src/container/tenant_builder.rs | 1 - 5 files changed, 24 insertions(+), 7 deletions(-) diff --git a/src/container/builder.rs b/src/container/builder.rs index 17ebde10b1..9d6d0bc53e 100644 --- a/src/container/builder.rs +++ b/src/container/builder.rs @@ -3,14 +3,16 @@ use std::path::PathBuf; use super::{init_builder::InitContainerBuilder, tenant_builder::TenantContainerBuilder}; pub struct ContainerBuilder { + /// Id of the container pub(super) container_id: String, - + /// Root directory for container state pub(super) root_path: PathBuf, - + /// Interface to operating system primitives pub(super) syscall: LinuxSyscall, - + /// File which will be used to communicate the pid of the + /// container process to the higher level runtime pub(super) pid_file: Option, - + /// Socket to communicate the file descriptor of the ptty pub(super) console_socket: Option, } diff --git a/src/container/builder_impl.rs b/src/container/builder_impl.rs index 50d3285aba..fd50321853 100644 --- a/src/container/builder_impl.rs +++ b/src/container/builder_impl.rs @@ -21,18 +21,30 @@ use crate::{ use super::{Container, ContainerStatus}; pub(super) struct ContainerBuilderImpl { + /// Flag indicating if an init or a tenant container should be created pub init: bool, + /// Interface to operating system primitives pub syscall: LinuxSyscall, + /// Flag indicating if systemd should be used for cgroup management pub use_systemd: bool, + /// Id of the container pub container_id: String, - pub root_path: PathBuf, + /// Directory where the state of the container will be stored pub container_dir: PathBuf, + /// OCI complient runtime spec pub spec: Spec, + /// Root filesystem of the container pub rootfs: PathBuf, + /// File which will be used to communicate the pid of the + /// container process to the higher level runtime pub pid_file: Option, + /// Socket to communicate the file descriptor of the ptty pub console_socket: Option, + /// Options for rootless containers pub rootless: Option, + /// Socket to communicate container start pub notify_socket: NotifyListener, + /// Container state pub container: Option, } diff --git a/src/container/init_builder.rs b/src/container/init_builder.rs index 7eab411ebe..a6d1089ba0 100644 --- a/src/container/init_builder.rs +++ b/src/container/init_builder.rs @@ -72,7 +72,6 @@ impl InitContainerBuilder { init: true, syscall: self.base.syscall, container_id: self.base.container_id, - root_path: self.base.root_path, pid_file: self.base.pid_file, console_socket: csocketfd, use_systemd: self.use_systemd, diff --git a/src/container/mod.rs b/src/container/mod.rs index 59873ad225..d478e28461 100644 --- a/src/container/mod.rs +++ b/src/container/mod.rs @@ -1,4 +1,9 @@ //! Container management +/// This crate is responsible for the creation of containers. It provides a builder that can +/// be used to configure and create containers. We distinguish between an init container for which +/// namespaces and cgroups will be created (usually) and a tenant container process that will move +/// into the existing namespaces and cgroups of the initial container process (e.g. used to implement +/// the exec command). pub mod builder; mod builder_impl; diff --git a/src/container/tenant_builder.rs b/src/container/tenant_builder.rs index 1e7cbe08eb..a3bcff0627 100644 --- a/src/container/tenant_builder.rs +++ b/src/container/tenant_builder.rs @@ -113,7 +113,6 @@ impl TenantContainerBuilder { init: false, syscall: self.base.syscall, container_id: self.base.container_id, - root_path: self.base.root_path, pid_file: self.base.pid_file, console_socket: csocketfd, use_systemd,