Skip to content

Commit 3c0855a

Browse files
authored
Removes process tree generation subcommand (#1394)
### What does this PR do? Removes an unused cli subcommand. ### Motivation [YAGNI](https://en.wikipedia.org/wiki/You_aren%27t_gonna_need_it) ### Related issues ### Additional Notes
1 parent 9152865 commit 3c0855a

File tree

2 files changed

+4
-79
lines changed

2 files changed

+4
-79
lines changed

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
1414
- `unix_stream` generator now supports `parallel_connections` in a manner similar to
1515
`unix_datagram`.
1616
- Added a `/proc/vmstat` observer.
17+
## Changed
18+
- 'lading process-tree-gen' command is removed as it is currently unused
1719

1820
## [0.26.0]
1921
## Added

lading/src/bin/lading.rs

Lines changed: 2 additions & 79 deletions
Original file line numberDiff line numberDiff line change
@@ -7,21 +7,19 @@ use std::{
77
str::FromStr,
88
};
99

10-
use clap::{ArgGroup, Parser, Subcommand};
10+
use clap::{ArgGroup, Parser};
1111
use jemallocator::Jemalloc;
1212
use lading::{
1313
blackhole,
1414
captures::CaptureManager,
1515
config::{Config, Telemetry},
16-
generator::{self, process_tree},
17-
inspector, observer,
16+
generator, inspector, observer,
1817
target::{self, Behavior, Output},
1918
target_metrics,
2019
};
2120
use metrics::gauge;
2221
use metrics_exporter_prometheus::PrometheusBuilder;
2322
use once_cell::sync::Lazy;
24-
use rand::{SeedableRng, rngs::StdRng};
2523
use regex::Regex;
2624
use rustc_hash::FxHashMap;
2725
use tokio::{
@@ -60,8 +58,6 @@ enum Error {
6058
CapturePath,
6159
#[error("Invalid path for prometheus socket")]
6260
PrometheusPath,
63-
#[error("Process tree failed to generate tree")]
64-
ProcessTree(#[from] process_tree::Error),
6561
#[error(transparent)]
6662
Registration(#[from] lading_signal::RegisterError),
6763
}
@@ -212,30 +208,6 @@ struct Opts {
212208
/// whether to ignore inspector configuration, if present, and not run the inspector
213209
#[clap(long)]
214210
disable_inspector: bool,
215-
/// Extra sub commands
216-
#[clap(subcommand)]
217-
extracmds: Option<ExtraCommands>,
218-
}
219-
220-
#[derive(Subcommand, Debug)]
221-
#[clap(hide = true)]
222-
enum ExtraCommands {
223-
ProcessTreeGen(ProcessTreeGen),
224-
}
225-
226-
#[derive(Parser, Debug)]
227-
#[clap(group(
228-
ArgGroup::new("config")
229-
.required(true)
230-
.args(&["config-path", "config-content"]),
231-
))]
232-
struct ProcessTreeGen {
233-
/// path on disk to the configuration file
234-
#[clap(long)]
235-
config_path: Option<PathBuf>,
236-
/// string repesanting the configuration
237-
#[clap(long)]
238-
config_content: Option<String>,
239211
}
240212

241213
fn get_config(ops: &Opts, config: Option<String>) -> Result<Config, Error> {
@@ -591,49 +563,6 @@ async fn inner_main(
591563
res
592564
}
593565

594-
fn run_process_tree(opts: ProcessTreeGen) -> Result<(), Error> {
595-
let mut contents = String::new();
596-
597-
if let Some(path) = opts.config_path {
598-
debug!(
599-
"Attempting to open configuration file at: {}",
600-
path.display()
601-
);
602-
let mut file: std::fs::File = std::fs::OpenOptions::new()
603-
.read(true)
604-
.open(&path)
605-
.unwrap_or_else(|_| panic!("Could not open configuration file at: {}", path.display()));
606-
607-
file.read_to_string(&mut contents)?;
608-
} else if let Some(str) = &opts.config_content {
609-
contents = str.to_string()
610-
} else {
611-
unreachable!("clap ensures that exactly one target option is selected");
612-
};
613-
614-
match process_tree::get_config(&contents) {
615-
Ok(config) => {
616-
info!("Generating a process tree.");
617-
618-
let mut rng = StdRng::from_seed(config.seed);
619-
let nodes = process_tree::generate_tree(&mut rng, &config)?;
620-
621-
process_tree::spawn_tree(&nodes, config.process_sleep_ns.get())?;
622-
623-
info!("Bye. :)");
624-
}
625-
Err(e) => panic!("invalide configuration: {e}"),
626-
}
627-
Ok(())
628-
}
629-
630-
fn run_extra_cmds(cmds: ExtraCommands) -> Result<(), Error> {
631-
match cmds {
632-
// This command will call fork and the process must be kept fork-safe up to this point.
633-
ExtraCommands::ProcessTreeGen(opts) => run_process_tree(opts),
634-
}
635-
}
636-
637566
fn main() -> Result<(), Error> {
638567
tracing_subscriber::fmt()
639568
.with_env_filter(EnvFilter::from_default_env())
@@ -645,12 +574,6 @@ fn main() -> Result<(), Error> {
645574
info!("Starting lading {version} run.");
646575
let opts: Opts = Opts::parse();
647576

648-
// handle extra commands
649-
if let Some(cmds) = opts.extracmds {
650-
run_extra_cmds(cmds)?;
651-
return Ok(());
652-
}
653-
654577
let config = get_config(&opts, None);
655578

656579
let experiment_duration = if opts.experiment_duration_infinite {

0 commit comments

Comments
 (0)