Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for pause #908

Merged
merged 1 commit into from
Jan 26, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -95,14 +95,14 @@ linters:
# - wsl
linters-settings:
funlen:
lines: 100
lines: 120
statements: 50
varnamelen:
min-name-length: 1
cyclop:
max-complexity: 20
max-complexity: 25
gocognit:
min-complexity: 30
min-complexity: 35
nestif:
min-complexity: 15
errcheck:
Expand Down
12 changes: 12 additions & 0 deletions Cargo.lock

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

27 changes: 27 additions & 0 deletions conmon-rs/common/proto/conmon.capnp
Original file line number Diff line number Diff line change
Expand Up @@ -120,4 +120,31 @@ interface Conmon {
}

setWindowSizeContainer @5 (request: SetWindowSizeRequest) -> (response: SetWindowSizeResponse);

###############################################
# CreateNamespaces
struct CreateNamespacesRequest {
metadata @0 :Data; # Standard metadata to carry.
namespaces @1 :List(Namespace); # The list of namespaces to unshare.
}

enum Namespace {
ipc @0; # Unshare the IPC namespace.
net @1; # Unshare the network namespace.
pid @2; # Unshare the PID namespace.
user @3; # Unshare the user namespace.
uts @4; # Unshare the UTS namespace.
}

struct CreateNamespacesResponse {
namespaces @0 :List(NamespaceResponse); # The list of created namespaces.
}

# Available namespaces.
struct NamespaceResponse {
type @0 :Namespace; # The type of the namespace.
path @1 :Text; # Path to the directory for the unshared namespaces.
}

createNamespaces @6 (request: CreateNamespacesRequest) -> (response: CreateNamespacesResponse);
}
2 changes: 2 additions & 0 deletions conmon-rs/server/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ memchr = "2.5.0"
multimap = "0.8.3"
nix = "0.26.2"
notify = "5.0.0"
once_cell = "1.17.0"
opentelemetry = { version = "0.18.0", features = ["rt-tokio"] }
opentelemetry-otlp = "0.11.0"
opentelemetry-semantic-conventions = "0.10.0"
Expand All @@ -31,6 +32,7 @@ sendfd = { version = "0.4.3", features = ["tokio"] }
serde = { version = "1.0.152", features = ["derive"] }
serde_json = "1.0.91"
shadow-rs = "=0.16.1"
signal-hook = "0.3.14"
strum = { version = "0.24.1", features = ["derive"] }
tempfile = "3.3.0"
tokio = { version = "1.24.2", features = ["fs", "io-std", "io-util", "macros", "net", "process", "rt", "rt-multi-thread", "signal", "time"] }
Expand Down
44 changes: 42 additions & 2 deletions conmon-rs/server/src/config.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
//! Configuration related structures
use anyhow::{bail, Result};
use clap::{ArgEnum, Parser};
use clap::{ArgEnum, Parser, Subcommand};
use getset::{CopyGetters, Getters, Setters};
use serde::{Deserialize, Serialize};
use std::{fs, path::PathBuf};
Expand All @@ -18,9 +18,13 @@ macro_rules! prefix {
after_help("More info at: https://github.com/containers/conmon-rs"),
disable_version_flag(true)
)]

/// An OCI container runtime monitor.
pub struct Config {
#[get = "pub"]
#[clap(subcommand)]
/// Possible subcommands.
command: Option<Commands>,

#[get_copy = "pub"]
#[clap(
default_missing_value("default"),
Expand Down Expand Up @@ -129,6 +133,42 @@ pub struct Config {
tracing_endpoint: String,
}

#[derive(Clone, Debug, Deserialize, Eq, PartialEq, Serialize, Subcommand)]
/// Possible subcommands.
pub enum Commands {
/// Run pause instead of the server.
Pause {
#[clap(
env(concat!(prefix!(), "PAUSE_PATH")),
long("path"),
short('p'),
value_name("PATH")
)]
/// The base path for pinning the namespaces.
path: PathBuf,

#[clap(long("ipc"))]
/// Unshare the IPC namespace.
ipc: bool,

#[clap(long("pid"))]
/// Unshare the PID namespace.
pid: bool,

#[clap(long("net"))]
/// Unshare the network namespace.
net: bool,

#[clap(long("user"))]
/// Unshare the user namespace.
user: bool,

#[clap(long("uts"))]
/// Unshare the UTS namespace.
uts: bool,
},
}

#[derive(
ArgEnum,
AsRefStr,
Expand Down
1 change: 1 addition & 0 deletions conmon-rs/server/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ mod init;
mod journal;
mod listener;
mod oom_watcher;
mod pause;
mod rpc;
mod server;
mod streams;
Expand Down
Loading