Skip to content

Commit

Permalink
Merge branch 'main' into meowchinist/mbe-578-add-prometheus-export-po…
Browse files Browse the repository at this point in the history
…int-to-the-agent-pod
  • Loading branch information
meowjesty authored Jan 6, 2025
2 parents 101dd99 + 1a23d56 commit 2dd3ab0
Show file tree
Hide file tree
Showing 12 changed files with 466 additions and 354 deletions.
1 change: 1 addition & 0 deletions changelog.d/+mirrord-policy-rejection.fixed.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Fixed a bug where port mirroring block (due to active mirrord policies) would terminate the mirrord session.
1 change: 1 addition & 0 deletions changelog.d/2868.changed.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Updated how intproxy is outputing logfile when using container mode, now logs will be written on host machine.
3 changes: 2 additions & 1 deletion mirrord/cli/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -63,11 +63,12 @@ tempfile.workspace = true
rcgen.workspace = true
rustls-pemfile.workspace = true
tokio-rustls.workspace = true
tokio-stream = { workspace = true, features = ["net"] }
tokio-stream = { workspace = true, features = ["io-util", "net"] }
regex.workspace = true
mid = "3.0.0"
rand.workspace = true


[target.'cfg(target_os = "macos")'.dependencies]
mirrord-sip = { path = "../sip" }

Expand Down
33 changes: 28 additions & 5 deletions mirrord/cli/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -834,6 +834,13 @@ pub struct RuntimeArgs {
/// Supported command for using mirrord with container runtimes.
#[derive(Subcommand, Debug, Clone)]
pub(super) enum ContainerRuntimeCommand {
/// Execute a `<RUNTIME> create` command with mirrord loaded. (not supported with )
#[command(hide = true)]
Create {
/// Arguments that will be propogated to underlying `<RUNTIME> create` command.
#[arg(allow_hyphen_values = true, trailing_var_arg = true)]
runtime_args: Vec<String>,
},
/// Execute a `<RUNTIME> run` command with mirrord loaded.
Run {
/// Arguments that will be propogated to underlying `<RUNTIME> run` command.
Expand All @@ -843,14 +850,17 @@ pub(super) enum ContainerRuntimeCommand {
}

impl ContainerRuntimeCommand {
pub fn run<T: Into<String>>(runtime_args: impl IntoIterator<Item = T>) -> Self {
ContainerRuntimeCommand::Run {
pub fn create<T: Into<String>>(runtime_args: impl IntoIterator<Item = T>) -> Self {
ContainerRuntimeCommand::Create {
runtime_args: runtime_args.into_iter().map(T::into).collect(),
}
}

pub fn has_publish(&self) -> bool {
let ContainerRuntimeCommand::Run { runtime_args } = self;
let runtime_args = match self {
ContainerRuntimeCommand::Run { runtime_args } => runtime_args,
_ => return false,
};

let mut hit_trailing_token = false;

Expand All @@ -860,6 +870,15 @@ impl ContainerRuntimeCommand {
!hit_trailing_token && matches!(runtime_arg.as_str(), "-p" | "--publish")
})
}

pub fn into_parts(self) -> (Vec<String>, Vec<String>) {
match self {
ContainerRuntimeCommand::Create { runtime_args } => {
(vec!["create".to_owned()], runtime_args)
}
ContainerRuntimeCommand::Run { runtime_args } => (vec!["run".to_owned()], runtime_args),
}
}
}

#[derive(Args, Debug)]
Expand Down Expand Up @@ -947,7 +966,9 @@ mod tests {

assert_eq!(runtime_args.runtime, ContainerRuntime::Podman);

let ContainerRuntimeCommand::Run { runtime_args } = runtime_args.command;
let ContainerRuntimeCommand::Run { runtime_args } = runtime_args.command else {
panic!("expected run command");
};

assert_eq!(runtime_args, vec!["-it", "--rm", "debian"]);
}
Expand All @@ -965,7 +986,9 @@ mod tests {

assert_eq!(runtime_args.runtime, ContainerRuntime::Podman);

let ContainerRuntimeCommand::Run { runtime_args } = runtime_args.command;
let ContainerRuntimeCommand::Run { runtime_args } = runtime_args.command else {
panic!("expected run command");
};

assert_eq!(runtime_args, vec!["-it", "--rm", "debian"]);
}
Expand Down
Loading

0 comments on commit 2dd3ab0

Please sign in to comment.