Skip to content
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
5 changes: 3 additions & 2 deletions io-thread-controller.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
"cooldown_secs": 10.0,
"engine": "threshold",
"engine_config_dir": "/etc/io-thread-controller.d/engines",
"backend_config_dir": "/etc/io-thread-controller.d/backends"
"vm_state_path": "/run/io-thread-controller/vm-ownership.json"
"backend_config_dir": "/etc/io-thread-controller.d/backends",
"vm_state_path": "/run/io-thread-controller/vm-ownership.json",
"dry_run": false
}
5 changes: 5 additions & 0 deletions src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,10 @@ pub struct Config {
/// Emit a one-time legend for status-line fields at startup.
#[serde(default)]
pub print_status_header: bool,
/// When true, log the scaling verdict but skip the actuation
/// call to `set_thread_count`.
#[serde(default)]
pub dry_run: bool,
}

fn default_true() -> bool {
Expand Down Expand Up @@ -127,6 +131,7 @@ impl Default for Config {
enable_per_vm_status_line: true,
enable_aggregate_status_line: true,
print_status_header: false,
dry_run: false,
}
}
}
Expand Down
25 changes: 25 additions & 0 deletions src/controller.rs
Original file line number Diff line number Diff line change
Expand Up @@ -650,6 +650,31 @@ impl Controller {
return Ok(());
}

if self.cfg.dry_run {
tracing::info!(
target: "controller",
vm = %instance.id,
action = %action,
target,
"dry-run: would scale"
);
if matches!(action, ScaleAction::Up(_) | ScaleAction::Down(_)) {
instance.status.write().await.cooldown_until =
Some(Instant::now() + Duration::from_secs_f64(self.cfg.cooldown_secs));
}
self.engine
.on_applied(
&instance.id,
AppliedOutcome::DryRun {
action,
prev_thread_count: previous_count,
prev_io_count_total: previous_io_count,
},
)
.await;
return Ok(());
}

match instance.client.set_thread_count(target).await {
Ok(()) => {
let mut status = instance.status.write().await;
Expand Down
6 changes: 6 additions & 0 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,9 @@ struct Cli {
/// Emit a one-time legend for uptime-style status fields.
#[arg(long)]
print_status_header: bool,
/// Log scaling decisions without calling set_thread_count.
#[arg(long)]
dry_run: bool,
}

/// See `Cli::log_style`.
Expand Down Expand Up @@ -123,6 +126,9 @@ async fn main() -> Result<(), IoThreadControllerError> {
if cli.print_status_header {
cfg.print_status_header = true;
}
if cli.dry_run {
cfg.dry_run = true;
}
validate_config(&cfg)?;
let backends = registered_backends(&cfg)?;
run(cfg, backends).await?;
Expand Down
Loading