doczkal / rpms / abrt

Forked from rpms/abrt 4 years ago
Clone

Blame SOURCES/0018-don-t-break-the-event-run-by-failures-of-abrt-action.patch

b404a9
From e6b19714485e72be99a9fcce62cd3a8a0e95808f Mon Sep 17 00:00:00 2001
b404a9
From: Jakub Filak <jfilak@redhat.com>
b404a9
Date: Fri, 24 Jan 2014 14:26:02 +0100
b404a9
Subject: [ABRT PATCH 18/27] don't break the event run by failures of
b404a9
 abrt-action-notify
b404a9
b404a9
Closes #789
b404a9
Closes rhbz#1057710
b404a9
b404a9
rmarko: add newlines to sys.stderr.write calls
b404a9
b404a9
Signed-off-by: Jakub Filak <jfilak@redhat.com>
b404a9
---
b404a9
 src/daemon/abrt_event.conf     |  2 ++
b404a9
 src/plugins/abrt-action-notify | 48 ++++++++++++++++++++++++------------------
b404a9
 2 files changed, 30 insertions(+), 20 deletions(-)
b404a9
b404a9
diff --git a/src/daemon/abrt_event.conf b/src/daemon/abrt_event.conf
b404a9
index 8a8e862..fe9c3d5 100644
b404a9
--- a/src/daemon/abrt_event.conf
b404a9
+++ b/src/daemon/abrt_event.conf
b404a9
@@ -104,7 +104,9 @@ EVENT=open-gui
b404a9
 # Notify a new crash
b404a9
 EVENT=notify package!=
b404a9
         abrt-action-notify -d $DUMP_DIR
b404a9
+        true # ignore failures because we want to run all 'notify' events
b404a9
 
b404a9
 # Notify a new occurrence of a single crash
b404a9
 EVENT=notify-dup package!=
b404a9
         abrt-action-notify -d $DUMP_DIR
b404a9
+        true # ignore failures because we want to run all 'notify' events
b404a9
diff --git a/src/plugins/abrt-action-notify b/src/plugins/abrt-action-notify
b404a9
index 72bfbf8..cbabf74 100644
b404a9
--- a/src/plugins/abrt-action-notify
b404a9
+++ b/src/plugins/abrt-action-notify
b404a9
@@ -216,17 +216,22 @@ if __name__ == "__main__":
b404a9
                 format(DIR_PATH, ex.message))
b404a9
         sys.exit(RETURN_FAILURE)
b404a9
 
b404a9
+    # The execution must continue because we should try to notify via all
b404a9
+    # configured channels. One of them might work properly.
b404a9
+    return_status = RETURN_OK
b404a9
     try:
b404a9
         emit_crash_dbus_signal(PD)
b404a9
     except RuntimeError as ex:
b404a9
-        sys.stderr.write("Cannot notify '{0}': {1}\n".
b404a9
+        sys.stderr.write("Cannot notify '{0}' via D-Bus: {1}\n".
b404a9
                 format(DIR_PATH, ex.message))
b404a9
-        sys.exit(RETURN_FAILURE)
b404a9
+        return_status = RETURN_FAILURE
b404a9
     except KeyError as ex:
b404a9
         # this is a bug in build_notification_problem_data()
b404a9
         sys.stderr.write("BUG: problem data misses required element '{0}'"
b404a9
-                .format(ex.message))
b404a9
-        sys.exit(RETURN_FAILURE)
b404a9
+                         " required for D-Bus notification\n"
b404a9
+                         .format(ex.message))
b404a9
+
b404a9
+        return_status = RETURN_FAILURE
b404a9
 
b404a9
     if OPTIONS.autoreporting or conf.get("AutoreportingEnabled", "no") == "yes":
b404a9
         event_name = OPTIONS.autoreporting_event
b404a9
@@ -234,20 +239,23 @@ if __name__ == "__main__":
b404a9
             if "AutoreportingEvent" in conf:
b404a9
                 event_name = conf["AutoreportingEvent"]
b404a9
             else:
b404a9
-                sys.stderr.write("Autoreporting event is not configured")
b404a9
-                sys.exit(RETURN_FAILURE)
b404a9
-
b404a9
-        try:
b404a9
-            run_autoreport(PD, event_name)
b404a9
-        except RuntimeError as ex:
b404a9
-            sys.stderr.write("Cannot notify '{0}': {1}\n".
b404a9
-                    format(DIR_PATH, ex.message))
b404a9
-            sys.exit(RETURN_FAILURE)
b404a9
-        except KeyError as ex:
b404a9
-            # this is a bug in build_notification_problem_data()
b404a9
-            sys.stderr.write("BUG: problem data misses required element '{0}'"
b404a9
-                    .format(ex.message))
b404a9
-            sys.exit(RETURN_FAILURE)
b404a9
-
b404a9
-    sys.exit(RETURN_OK)
b404a9
+                sys.stderr.write("Autoreporting event is not configured\n")
b404a9
+                return_status = RETURN_FAILURE
b404a9
+
b404a9
+        if event_name:
b404a9
+            try:
b404a9
+                run_autoreport(PD, event_name)
b404a9
+            except RuntimeError as ex:
b404a9
+                sys.stderr.write("Cannot notify '{0}' via uReport: {1}\n".
b404a9
+                        format(DIR_PATH, ex.message))
b404a9
+                return_status = RETURN_FAILURE
b404a9
+            except KeyError as ex:
b404a9
+                # this is a bug in build_notification_problem_data()
b404a9
+                sys.stderr.write(
b404a9
+                    "BUG: problem data misses required element '{0}'"
b404a9
+                    " required for uReport notification\n".format(ex.message))
b404a9
+
b404a9
+                return_status = RETURN_FAILURE
b404a9
+
b404a9
+    sys.exit(return_status)
b404a9
 
b404a9
-- 
b404a9
1.8.3.1
b404a9