forked from DGNum/colmena
Exit with non-zero code if any node fails to deploy
The exit codes are in flux and should not be relied upon. Fixes #28.
This commit is contained in:
parent
960af8f793
commit
22ae18f5e7
3 changed files with 23 additions and 6 deletions
|
@ -233,9 +233,13 @@ pub async fn run(_global_args: &ArgMatches<'_>, local_args: &ArgMatches<'_>) {
|
||||||
|
|
||||||
let deployment = Arc::new(deployment);
|
let deployment = Arc::new(deployment);
|
||||||
|
|
||||||
if goal_arg == "keys" {
|
let success = if goal_arg == "keys" {
|
||||||
deployment.upload_keys().await;
|
deployment.upload_keys().await
|
||||||
} else {
|
} else {
|
||||||
deployment.execute().await;
|
deployment.execute().await
|
||||||
|
};
|
||||||
|
|
||||||
|
if !success {
|
||||||
|
quit::with_code(10);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -126,7 +126,11 @@ pub async fn run(_global_args: &ArgMatches<'_>, local_args: &ArgMatches<'_>) {
|
||||||
deployment.set_options(options);
|
deployment.set_options(options);
|
||||||
|
|
||||||
let deployment = Arc::new(deployment);
|
let deployment = Arc::new(deployment);
|
||||||
deployment.execute().await;
|
let success = deployment.execute().await;
|
||||||
|
|
||||||
|
if !success {
|
||||||
|
quit::with_code(10);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
async fn escalate(sudo: &str) -> ! {
|
async fn escalate(sudo: &str) -> ! {
|
||||||
|
|
|
@ -255,7 +255,7 @@ impl Deployment {
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Uploads keys only (user-facing)
|
/// Uploads keys only (user-facing)
|
||||||
pub async fn upload_keys(self: Arc<Self>) {
|
pub async fn upload_keys(self: Arc<Self>) -> bool {
|
||||||
let progress = {
|
let progress = {
|
||||||
let mut progress = Progress::default();
|
let mut progress = Progress::default();
|
||||||
progress.set_label_width(self.label_width);
|
progress.set_label_width(self.label_width);
|
||||||
|
@ -306,12 +306,14 @@ impl Deployment {
|
||||||
}
|
}
|
||||||
|
|
||||||
arc_self.print_logs().await;
|
arc_self.print_logs().await;
|
||||||
|
|
||||||
|
arc_self.all_successful().await
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Executes the deployment (user-facing)
|
/// Executes the deployment (user-facing)
|
||||||
///
|
///
|
||||||
/// Self must be wrapped inside an Arc.
|
/// Self must be wrapped inside an Arc.
|
||||||
pub async fn execute(self: Arc<Self>) {
|
pub async fn execute(self: Arc<Self>) -> bool {
|
||||||
let progress = {
|
let progress = {
|
||||||
let mut progress = if !self.options.progress_bar {
|
let mut progress = if !self.options.progress_bar {
|
||||||
Progress::with_style(OutputStyle::Plain)
|
Progress::with_style(OutputStyle::Plain)
|
||||||
|
@ -429,6 +431,13 @@ impl Deployment {
|
||||||
}
|
}
|
||||||
|
|
||||||
arc_self.print_logs().await;
|
arc_self.print_logs().await;
|
||||||
|
|
||||||
|
arc_self.all_successful().await
|
||||||
|
}
|
||||||
|
|
||||||
|
async fn all_successful(&self) -> bool {
|
||||||
|
let results = self.results.lock().await;
|
||||||
|
results.iter().filter(|r| !r.is_successful()).count() == 0
|
||||||
}
|
}
|
||||||
|
|
||||||
async fn print_logs(&self) {
|
async fn print_logs(&self) {
|
||||||
|
|
Loading…
Reference in a new issue