diff --git a/changelog.d/2367.added.md b/changelog.d/2367.added.md new file mode 100644 index 00000000000..235fd99e1fa --- /dev/null +++ b/changelog.d/2367.added.md @@ -0,0 +1 @@ +Added config info printout at session start. \ No newline at end of file diff --git a/mirrord/cli/src/extension.rs b/mirrord/cli/src/extension.rs index 4f8b8952871..6a452b856b7 100644 --- a/mirrord/cli/src/extension.rs +++ b/mirrord/cli/src/extension.rs @@ -6,7 +6,7 @@ use mirrord_progress::{JsonProgress, Progress, ProgressTracker}; use crate::{config::ExtensionExecArgs, error::CliError, execution::MirrordExecution, Result}; -/// Actualy facilitate execution after all preperatations were complete +/// Actually facilitate execution after all preparations were complete async fn mirrord_exec

( #[cfg(target_os = "macos")] executable: Option<&str>, env: HashMap, diff --git a/mirrord/cli/src/main.rs b/mirrord/cli/src/main.rs index ca3084f9cec..444f6a2b32a 100644 --- a/mirrord/cli/src/main.rs +++ b/mirrord/cli/src/main.rs @@ -22,6 +22,7 @@ use miette::JSONReportHandler; use mirrord_analytics::{AnalyticsError, AnalyticsReporter, CollectAnalytics, Reporter}; use mirrord_config::{ config::{ConfigContext, MirrordConfig}, + feature::{fs::FsModeConfig, network::incoming::IncomingMode}, target::TargetDisplay, LayerConfig, LayerFileConfig, }; @@ -102,6 +103,17 @@ where // Put original executable in argv[0] even if actually running patched version. binary_args.insert(0, args.binary.clone()); + // Print config details for the user + let mut sub_progress_config = progress.subtask("config summary"); + print_config( + &sub_progress_config, + Some(&binary), + Some(&args.binary_args), + &config, + false, + ); + sub_progress_config.success(None); + sub_progress.success(Some("ready to launch process")); // The execve hook is not yet active and does not hijack this call. let err = execvp(binary.clone(), binary_args.clone()); @@ -119,6 +131,103 @@ where Err(CliError::BinaryExecuteFailed(binary, binary_args)) } +fn print_config

( + progress_subtask: &P, + binary: Option<&String>, + binary_args: Option<&Vec>, + config: &LayerConfig, + single_msg: bool, +) where + P: Progress + Send + Sync, +{ + let mut messages = vec![]; + if let Some(b) = binary + && let Some(a) = binary_args + { + messages.push(format!("Running binary \"{}\" with arguments: {:?}.", b, a)); + } + + let target_info = if let Some(target) = &config.target.path { + &format!("mirrord will target: {}", target)[..] + } else { + "mirrord will run without a target" + }; + let config_info = if let Ok(path) = std::env::var("MIRRORD_CONFIG_FILE") { + &format!("a configuration file was loaded from: {} ", path)[..] + } else { + "no configuration file was loaded" + }; + messages.push(format!("{}, {}", target_info, config_info)); + + let operator_info = match config.operator { + Some(true) => "be used", + Some(false) => "not be used", + None => "be used if possible", + }; + messages.push(format!("operator: the operator will {}", operator_info)); + + let exclude = config.feature.env.exclude.as_ref(); + let include = config.feature.env.include.as_ref(); + let env_info = if let Some(excluded) = exclude { + if excluded.clone().to_vec().contains(&String::from("*")) { + "no" + } else { + "not all" + } + } else if include.is_some() { + "not all" + } else { + "all" + }; + messages.push(format!( + "env: {} environment variables will be fetched", + env_info + )); + + let fs_info = match config.feature.fs.mode { + FsModeConfig::Read => "read only from the remote", + FsModeConfig::Write => "read and write from the remote", + _ => "read and write locally", + }; + messages.push(format!("fs: file operations will default to {}", fs_info)); + + let incoming_info = match config.feature.network.incoming.mode { + IncomingMode::Mirror => "mirrored", + IncomingMode::Steal => "stolen", + IncomingMode::Off => "ignored", + }; + messages.push(format!( + "incoming: incoming traffic will be {}", + incoming_info + )); + + let outgoing_info = match ( + config.feature.network.outgoing.tcp, + config.feature.network.outgoing.udp, + ) { + (true, true) => "enabled on TCP and UDP", + (true, false) => "enabled on TCP", + (false, true) => "enabled on UDP", + (false, false) => "disabled on TCP and UDP", + }; + messages.push(format!("outgoing: forwarding is {}", outgoing_info)); + + let dns_info = match config.feature.network.dns { + true => "remotely", + false => "locally", + }; + messages.push(format!("dns: DNS will be resolved {}", dns_info)); + + if single_msg { + let long_message = messages.join(". \n"); + progress_subtask.info(&long_message); + } else { + for m in messages { + progress_subtask.info(&m[..]); + } + } +} + async fn exec(args: &ExecArgs, watch: drain::Watch) -> Result<()> { let progress = ProgressTracker::from_env("mirrord exec"); if !args.disable_version_check {