From 17e74dffb96b95b9e3a72fd4611e0b0bd4405659 Mon Sep 17 00:00:00 2001
From: Alexander Tivelkov <ativelkov@mirantis.com>
Date: Tue, 13 Aug 2013 13:45:21 +0400
Subject: [PATCH] Conductor will properly log exceptions even if they are
 passed to failure blocks

Change-Id: I81113411bf7a1a05570c38043f9e029b678a0f77
---
 muranoconductor/cloud_formation.py | 6 ++++--
 muranoconductor/windows_agent.py   | 5 ++++-
 2 files changed, 8 insertions(+), 3 deletions(-)

diff --git a/muranoconductor/cloud_formation.py b/muranoconductor/cloud_formation.py
index 10bfc02..7b52241 100644
--- a/muranoconductor/cloud_formation.py
+++ b/muranoconductor/cloud_formation.py
@@ -42,11 +42,13 @@ def update_cf_stack(engine, context, body, template, result=None, error=None,
                 }
             failure_handler = body.find('failure')
             if failure_handler is not None:
-                log.warning("Handling exception in failure block")
+                log.warning("Handling exception in failure block",
+                            exc_info=True)
                 engine.evaluate_content(failure_handler, context)
                 return
             else:
-                log.error("No failure block found for exception")
+                log.error("No failure block found for exception",
+                          exc_info=True)
                 raise error_result
 
         success_handler = body.find('success')
diff --git a/muranoconductor/windows_agent.py b/muranoconductor/windows_agent.py
index 09494c6..01986cb 100644
--- a/muranoconductor/windows_agent.py
+++ b/muranoconductor/windows_agent.py
@@ -72,9 +72,12 @@ def send_command(engine, context, body, template, service, unit, mappings=None,
                 context[error] = errors
             failure_handler = body.find('failure')
             if failure_handler is not None:
+                log.warning(
+                    "Handling errors ({0}) in failure block".format(errors),
+                    exc_info=True)
                 engine.evaluate_content(failure_handler, context)
             else:
-                log.error("No failure block found for exception")
+                log.error("No failure block found for errors", exc_info=True)
                 if isinstance(result_value, AgentTimeoutException):
                     raise result_value
                 else: