nix: Small fixes to logging
This commit is contained in:
parent
ade2095919
commit
68ecb095b8
3 changed files with 30 additions and 9 deletions
|
@ -276,7 +276,9 @@ impl Deployment {
|
||||||
"Evaluating configurations for {} nodes"
|
"Evaluating configurations for {} nodes"
|
||||||
);
|
);
|
||||||
|
|
||||||
let drv = match arc_self.hive.eval_selected(&chunk, Some(bar.clone())).await {
|
let (eval, logs) = arc_self.hive.eval_selected(&chunk, Some(bar.clone())).await;
|
||||||
|
|
||||||
|
let drv = match eval {
|
||||||
Ok(drv) => {
|
Ok(drv) => {
|
||||||
bar.finish_and_clear();
|
bar.finish_and_clear();
|
||||||
drv
|
drv
|
||||||
|
@ -287,7 +289,7 @@ impl Deployment {
|
||||||
|
|
||||||
let mut results = arc_self.results.lock().await;
|
let mut results = arc_self.results.lock().await;
|
||||||
let stage = DeploymentStage::Evaluate(chunk.clone());
|
let stage = DeploymentStage::Evaluate(chunk.clone());
|
||||||
results.push(DeploymentResult::failure(stage, None));
|
results.push(DeploymentResult::failure(stage, logs));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
|
@ -59,8 +59,15 @@ impl Hive {
|
||||||
/// Evaluation may take up a lot of memory, so we make it possible
|
/// Evaluation may take up a lot of memory, so we make it possible
|
||||||
/// to split up the evaluation process into chunks and run them
|
/// to split up the evaluation process into chunks and run them
|
||||||
/// concurrently with other processes (e.g., build and apply).
|
/// concurrently with other processes (e.g., build and apply).
|
||||||
pub async fn eval_selected(&self, nodes: &Vec<String>, progress_bar: Option<ProgressBar>) -> NixResult<StoreDerivation<ProfileMap>> {
|
pub async fn eval_selected(&self, nodes: &Vec<String>, progress_bar: Option<ProgressBar>) -> (NixResult<StoreDerivation<ProfileMap>>, Option<String>) {
|
||||||
let nodes_expr = SerializedNixExpresssion::new(nodes)?;
|
// FIXME: The return type is ugly...
|
||||||
|
|
||||||
|
let nodes_expr = SerializedNixExpresssion::new(nodes);
|
||||||
|
if let Err(e) = nodes_expr {
|
||||||
|
return (Err(e), None);
|
||||||
|
}
|
||||||
|
let nodes_expr = nodes_expr.unwrap();
|
||||||
|
|
||||||
let expr = format!("hive.buildSelected {{ names = {}; }}", nodes_expr.expression());
|
let expr = format!("hive.buildSelected {{ names = {}; }}", nodes_expr.expression());
|
||||||
|
|
||||||
let command = self.nix_instantiate(&expr).instantiate();
|
let command = self.nix_instantiate(&expr).instantiate();
|
||||||
|
@ -71,11 +78,21 @@ impl Hive {
|
||||||
}
|
}
|
||||||
|
|
||||||
let eval = execution
|
let eval = execution
|
||||||
.capture_store_path().await?;
|
.capture_store_path().await;
|
||||||
let drv = eval.to_derivation()
|
|
||||||
.expect("The result should be a store derivation");
|
|
||||||
|
|
||||||
Ok(drv)
|
let (_, stderr) = execution.get_logs();
|
||||||
|
|
||||||
|
match eval {
|
||||||
|
Ok(path) => {
|
||||||
|
let drv = path.to_derivation()
|
||||||
|
.expect("The result should be a store derivation");
|
||||||
|
|
||||||
|
(Ok(drv), stderr.cloned())
|
||||||
|
}
|
||||||
|
Err(e) => {
|
||||||
|
(Err(e), stderr.cloned())
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Evaluates an expression using values from the configuration
|
/// Evaluates an expression using values from the configuration
|
||||||
|
|
|
@ -149,7 +149,9 @@ impl Host for Local {
|
||||||
|
|
||||||
execution.run().await?;
|
execution.run().await?;
|
||||||
|
|
||||||
let (stdout, _) = execution.get_logs();
|
let (stdout, stderr) = execution.get_logs();
|
||||||
|
self.logs += stderr.unwrap();
|
||||||
|
|
||||||
stdout.unwrap().lines().map(|p| p.to_string().try_into()).collect()
|
stdout.unwrap().lines().map(|p| p.to_string().try_into()).collect()
|
||||||
}
|
}
|
||||||
async fn activate(&mut self, profile: &Profile, goal: DeploymentGoal) -> NixResult<()> {
|
async fn activate(&mut self, profile: &Profile, goal: DeploymentGoal) -> NixResult<()> {
|
||||||
|
|
Loading…
Add table
Reference in a new issue