From eef408c1b304d43b4f9826cbc5b7c346a360fb21 Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Wed, 7 Mar 2012 14:26:28 +0100 Subject: [PATCH] record failing host and continue Signed-off-by: Nico Schottelius --- bin/cdist | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/bin/cdist b/bin/cdist index 79b8cae3..d291beb0 100755 --- a/bin/cdist +++ b/bin/cdist @@ -129,29 +129,29 @@ def configinstall(args, mode): process[host] = multiprocessing.Process(target=configinstall_onehost, args=(host, args, mode, True)) process[host].start() else: - if not configinstall_onehost(host, args, mode, parallel=False): + try: + configinstall_onehost(host, args, mode, parallel=False) + except cdist.Error as e: + # FIXME: save the error and display at the end? + # Would be non-consistent to parallel mode failed_hosts.append(host) + # Catch errors in parallel mode when joining if args.parallel: - for p in process.keys(): - log.debug("Joining process %s", p) - process[p].join() + for host in process.keys(): + log.debug("Joining process %s", host) + process[host].join() - if not process[p].exitcode == 0: - failed_hosts.append(p) - - if len(failed_hosts) > 0: - log.warn("Failed to deploy to the following hosts: " + - " ".join(failed_hosts)) + if not process[host].exitcode == 0: + failed_hosts.append(host) time_end = time.time() log.info("Total processing time for %s host(s): %s", len(args.host), (time_end - time_start)) if len(failed_hosts) > 0: - return False - else: - return True + raise cdist.Error("Failed to deploy to the following hosts: " + + " ".join(failed_hosts)) def configinstall_onehost(host, args, mode, parallel): """Configure or install ONE remote system"""