fix: make exec_in_container return errors instead of silently warning

- Changed from warn() to error() and return Err()
- Added info logging for each command executed
- Now we can see why downloads/installs fail
This commit is contained in:
Rodrigo Rodriguez (Pragmatismo) 2025-12-19 19:59:15 -03:00
parent 9a3ac6141e
commit bc3b3845b4
2 changed files with 28 additions and 3 deletions

View file

@ -5,6 +5,24 @@
---
## Build Rules - IMPORTANT
**Always use debug builds during development and testing:**
```bash
# CORRECT - debug build (fast compilation)
cargo build
cargo check
# WRONG - do NOT use release builds unless explicitly requested
# cargo build --release
```
Debug builds compile much faster and are sufficient for testing functionality.
Only use `--release` when building final binaries for deployment.
---
## Weekly Maintenance - EVERY MONDAY
### Package Review Checklist

View file

@ -1028,14 +1028,21 @@ Store credentials in Vault:
Ok(())
}
pub fn exec_in_container(&self, container: &str, command: &str) -> Result<()> {
info!("Executing in container {}: {}", container, command);
let output = Command::new("lxc")
.args(&["exec", container, "--", "bash", "-c", command])
.output()?;
if !output.status.success() {
warn!(
"Container command failed: {}",
String::from_utf8_lossy(&output.stderr)
let stderr = String::from_utf8_lossy(&output.stderr);
let stdout = String::from_utf8_lossy(&output.stdout);
error!(
"Container command failed.\nCommand: {}\nStderr: {}\nStdout: {}",
command, stderr, stdout
);
return Err(anyhow::anyhow!(
"Container command failed: {}",
if stderr.is_empty() { stdout.to_string() } else { stderr.to_string() }
));
}
Ok(())
}