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
31 changes: 20 additions & 11 deletions src/controller.rs
Original file line number Diff line number Diff line change
Expand Up @@ -278,6 +278,9 @@ impl Controller {
DbusRequest::GetSnapshot { reply } => {
let _ = reply.send(self.handle_get_snapshot().await);
}
DbusRequest::GetVersion { reply } => {
let _ = reply.send(env!("CARGO_PKG_VERSION").to_string());
}
DbusRequest::GetIoThreadVqMapping { vm, device, reply } => {
let result = match self.instances.get(&vm) {
Some(instance) => instance
Expand Down Expand Up @@ -559,8 +562,10 @@ impl Controller {
.await;
tracing::info!(
target: "controller",
id = %instance.id,
""
event = "scale_blocked",
reason = "manual_override",
vm = %instance.id,
action = %action
);
return Ok(());
}
Expand All @@ -570,8 +575,10 @@ impl Controller {
.await;
tracing::info!(
target: "controller",
id = %instance.id,
""
event = "scale_blocked",
reason = "unmanaged_vm",
vm = %instance.id,
action = %action
);
return Ok(());
}
Expand Down Expand Up @@ -664,10 +671,12 @@ impl Controller {
.await;
tracing::info!(
target: "controller",
id = %instance.id,
%action,
event = "scale_applied",
vm = %instance.id,
action = %action,
target,
""
prev_thread_count = previous_count,
prev_io_count_total = previous_io_count
);
}
Err(error) => {
Expand All @@ -677,11 +686,11 @@ impl Controller {
.await;
tracing::warn!(
target: "controller",
id = %instance.id,
%action,
event = "scale_failed",
vm = %instance.id,
action = %action,
target,
error = %error_text,
""
error = %error_text
);
}
}
Expand Down
10 changes: 10 additions & 0 deletions src/daemon.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,11 @@ use inotify::{Inotify, WatchMask};
use thiserror::Error;
use tokio::time::{MissedTickBehavior, interval};

pub const VERSION: &str = match option_env!("IO_THREAD_CONTROLLER_VERSION") {
Some(v) => v,
None => "unknown",
};

use crate::{
backends::Backend,
config::Config,
Expand Down Expand Up @@ -48,6 +53,11 @@ const INOTIFY_EVENT_BUF_SIZE: usize = 32 * 1024;

/// Run until SIGTERM or SIGINT.
pub async fn run(cfg: Config, backends: Vec<Box<dyn Backend>>) -> Result<(), DaemonError> {
tracing::info!(
target: "controller",
version = VERSION,
"io-thread-controller starting"
);
if cfg.print_status_header {
tracing::info!(
target: "status",
Expand Down
20 changes: 20 additions & 0 deletions src/dbus.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
//! Verbs currently exposed:
//! * debug-only `SetThreadCount(vm, threads, sticky)`;
//! * read-only `GetStats()`;
//! * read-only `GetVersion()`;
//! * named-IOThread and virtqueue-mapping operations for clients that support
//! them.

Expand Down Expand Up @@ -62,6 +63,11 @@ pub enum DbusRequest {
/// [`crate::controller::SnapshotPayload`] on success.
reply: oneshot::Sender<String>,
},
/// Return the controller binary version string.
GetVersion {
/// Reply channel carrying the version string.
reply: oneshot::Sender<String>,
},
/// Read the current virtqueue-to-IOThread mapping.
GetIoThreadVqMapping {
/// Instance / vm id to address.
Expand Down Expand Up @@ -190,6 +196,20 @@ impl Service {
await_with_timeout(rx).await
}

/// D-Bus wire signature: `GetVersion() -> s`.
///
/// Returns the controller binary version string (same source as startup
/// logs), exposed separately so high-frequency snapshot payloads stay
/// focused on dynamic metrics.
async fn get_version(&self) -> zbus::fdo::Result<String> {
let (tx, rx) = oneshot::channel();
self.tx
.send(DbusRequest::GetVersion { reply: tx })
.await
.map_err(|_| zbus::fdo::Error::Failed("controller channel closed".into()))?;
await_with_timeout(rx).await
}

async fn get_io_thread_vq_mapping(
&self,
vm: String,
Expand Down
7 changes: 6 additions & 1 deletion src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ use io_thread_controller::{
backends::BackendClientError,
backends::registered_backends,
config::{Config, ConfigError, dump_default_config, load_config, validate_config},
daemon::{DaemonError, run},
daemon::{DaemonError, VERSION, run},
util::Path,
};
use thiserror::Error;
Expand All @@ -37,6 +37,11 @@ enum IoThreadControllerError {

#[derive(Debug, Parser)]
#[command(
// Populated at build time by `build.rs` from the git tree
// (short hash, with `-dirty` when the tree had uncommitted
// changes). Falls back to `CARGO_PKG_VERSION` for tarball
// builds where `.git` is absent.
version = VERSION,
name = "io-thread-controller",
about = "Measure VM I/O workers and resize their pools through a selectable scaling engine."
)]
Expand Down
Loading