diff --git a/hostd/src/machine.rs b/hostd/src/machine.rs index b249576..1e49c89 100644 --- a/hostd/src/machine.rs +++ b/hostd/src/machine.rs @@ -1,12 +1,13 @@ use dropshot::{endpoint, HttpError, HttpResponseOk, RequestContext}; use schemars::JsonSchema; use serde::Serialize; -use std::sync::{Arc, Mutex}; use trace_request::trace_request; use systemd_ipc::addrs::SYSTEMD_HOSTNAME; use systemd_ipc::io_systemd_hostname::{self, VarlinkClientInterface}; +use std::sync::Arc; + use crate::context::ControllerContext; /// Version and build information @@ -24,19 +25,19 @@ struct MachineInfo { pub async fn describe( rqctx: RequestContext<Arc<ControllerContext>>, ) -> Result<HttpResponseOk<MachineInfo>, HttpError> { - let machine_info = tokio::task::spawn_blocking(move || { - // Connect to systemd.Hostname + // Connect to systemd.Hostname + // Make it tokio task blocking + tokio::task::block_in_place(move || { let conn = varlink::Connection::with_address(SYSTEMD_HOSTNAME).unwrap(); let mut sd = io_systemd_hostname::VarlinkClient::new(conn); - let machine_id = sd.describe().call().unwrap().MachineID; - MachineInfo { machine_id } + + tracing::info_span!("Hello, span hostd!"); + + tracing::info!(monotonic_counter.version_calls = 1); + + let machine_info = MachineInfo { machine_id }; + + Ok(HttpResponseOk(machine_info)) }) - .await - .unwrap(); - - tracing::info_span!("Hello, span hostd!"); - - tracing::info!(monotonic_counter.version_calls = 1); - Ok(HttpResponseOk(machine_info)) }