formatting
Some checks failed
CI / Security Blocking Checks (push) Successful in 34s
CI / Web Blocking Checks (push) Failing after 1m44s
CI / Rust Blocking Checks (push) Failing after 9m57s
CI / Web Advisory Checks (push) Successful in 1m14s
CI / Security Advisory Checks (push) Successful in 1m28s

This commit is contained in:
2026-03-04 23:46:31 -06:00
parent 13749409cd
commit f54eef3a14
3 changed files with 73 additions and 68 deletions

View File

@@ -947,60 +947,61 @@ async fn register_pack_internal(
// where the API host has the interpreter available. // where the API host has the interpreter available.
if let Some(ref env_cfg) = exec_config.environment { if let Some(ref env_cfg) = exec_config.environment {
if env_cfg.env_type != "none" if env_cfg.env_type != "none"
&& !env_dir.exists() && !env_cfg.create_command.is_empty() { && !env_dir.exists()
// Ensure parent directories exist && !env_cfg.create_command.is_empty()
if let Some(parent) = env_dir.parent() { {
let _ = std::fs::create_dir_all(parent); // Ensure parent directories exist
} if let Some(parent) = env_dir.parent() {
let _ = std::fs::create_dir_all(parent);
}
let vars = exec_config let vars = exec_config
.build_template_vars_with_env(&pack_path, Some(&env_dir)); .build_template_vars_with_env(&pack_path, Some(&env_dir));
let resolved_cmd = attune_common::models::runtime::RuntimeExecutionConfig::resolve_command( let resolved_cmd = attune_common::models::runtime::RuntimeExecutionConfig::resolve_command(
&env_cfg.create_command, &env_cfg.create_command,
&vars, &vars,
); );
tracing::info!( tracing::info!(
"Attempting to create {} environment (best-effort) at {}: {:?}", "Attempting to create {} environment (best-effort) at {}: {:?}",
env_cfg.env_type, env_cfg.env_type,
env_dir.display(), env_dir.display(),
resolved_cmd resolved_cmd
); );
if let Some((program, args)) = resolved_cmd.split_first() { if let Some((program, args)) = resolved_cmd.split_first() {
match tokio::process::Command::new(program) match tokio::process::Command::new(program)
.args(args) .args(args)
.current_dir(&pack_path) .current_dir(&pack_path)
.output() .output()
.await .await
{ {
Ok(output) if output.status.success() => { Ok(output) if output.status.success() => {
tracing::info!( tracing::info!(
"Created {} environment at {}", "Created {} environment at {}",
env_cfg.env_type, env_cfg.env_type,
env_dir.display() env_dir.display()
); );
} }
Ok(output) => { Ok(output) => {
let stderr = let stderr = String::from_utf8_lossy(&output.stderr);
String::from_utf8_lossy(&output.stderr); tracing::info!(
tracing::info!(
"Environment creation skipped in API service (exit {}): {}. \ "Environment creation skipped in API service (exit {}): {}. \
The worker will create it on first execution.", The worker will create it on first execution.",
output.status.code().unwrap_or(-1), output.status.code().unwrap_or(-1),
stderr.trim() stderr.trim()
); );
} }
Err(e) => { Err(e) => {
tracing::info!( tracing::info!(
"Runtime '{}' not available in API service: {}. \ "Runtime '{}' not available in API service: {}. \
The worker will create the environment on first execution.", The worker will create the environment on first execution.",
program, e program, e
); );
}
} }
} }
} }
}
} }
// Attempt to install dependencies if manifest file exists. // Attempt to install dependencies if manifest file exists.

View File

@@ -180,16 +180,18 @@ impl ApiClient {
let req = self.attach_body(self.build_request(method.clone(), path), body); let req = self.attach_body(self.build_request(method.clone(), path), body);
let response = req.send().await.context("Failed to send request to API")?; let response = req.send().await.context("Failed to send request to API")?;
if response.status() == StatusCode::UNAUTHORIZED && self.refresh_token.is_some() if response.status() == StatusCode::UNAUTHORIZED
&& self.refresh_auth_token().await? { && self.refresh_token.is_some()
// Retry with new token && self.refresh_auth_token().await?
let req = self.attach_body(self.build_request(method, path), body); {
let response = req // Retry with new token
.send() let req = self.attach_body(self.build_request(method, path), body);
.await let response = req
.context("Failed to send request to API (retry)")?; .send()
return self.handle_response(response).await; .await
} .context("Failed to send request to API (retry)")?;
return self.handle_response(response).await;
}
self.handle_response(response).await self.handle_response(response).await
} }
@@ -204,15 +206,17 @@ impl ApiClient {
let req = self.attach_body(self.build_request(method.clone(), path), body); let req = self.attach_body(self.build_request(method.clone(), path), body);
let response = req.send().await.context("Failed to send request to API")?; let response = req.send().await.context("Failed to send request to API")?;
if response.status() == StatusCode::UNAUTHORIZED && self.refresh_token.is_some() if response.status() == StatusCode::UNAUTHORIZED
&& self.refresh_auth_token().await? { && self.refresh_token.is_some()
let req = self.attach_body(self.build_request(method, path), body); && self.refresh_auth_token().await?
let response = req {
.send() let req = self.attach_body(self.build_request(method, path), body);
.await let response = req
.context("Failed to send request to API (retry)")?; .send()
return self.handle_empty_response(response).await; .await
} .context("Failed to send request to API (retry)")?;
return self.handle_empty_response(response).await;
}
self.handle_empty_response(response).await self.handle_empty_response(response).await
} }
@@ -391,16 +395,18 @@ impl ApiClient {
.await .await
.context("Failed to send multipart request to API")?; .context("Failed to send multipart request to API")?;
if response.status() == StatusCode::UNAUTHORIZED && self.refresh_token.is_some() if response.status() == StatusCode::UNAUTHORIZED
&& self.refresh_auth_token().await? { && self.refresh_token.is_some()
// Retry with new token && self.refresh_auth_token().await?
let req = build_multipart_request(self, &file_bytes)?; {
let response = req // Retry with new token
.send() let req = build_multipart_request(self, &file_bytes)?;
.await let response = req
.context("Failed to send multipart request to API (retry)")?; .send()
return self.handle_response(response).await; .await
} .context("Failed to send multipart request to API (retry)")?;
return self.handle_response(response).await;
}
self.handle_response(response).await self.handle_response(response).await
} }

View File

@@ -730,8 +730,7 @@ impl SensorInstance {
} }
/// Sensor status information /// Sensor status information
#[derive(Clone, Debug)] #[derive(Clone, Debug, Default)]
#[derive(Default)]
pub struct SensorStatus { pub struct SensorStatus {
/// Whether the sensor is running /// Whether the sensor is running
pub running: bool, pub running: bool,
@@ -746,7 +745,6 @@ pub struct SensorStatus {
pub last_poll: Option<chrono::DateTime<chrono::Utc>>, pub last_poll: Option<chrono::DateTime<chrono::Utc>>,
} }
#[cfg(test)] #[cfg(test)]
mod tests { mod tests {
use super::*; use super::*;