Blob Blame History Raw
From d798790c3a21611ec7ead55a7820b98019b2d0c7 Mon Sep 17 00:00:00 2001
From: Aravinda VK <avishwan@redhat.com>
Date: Wed, 21 Sep 2016 17:43:00 +0530
Subject: [PATCH 94/94] eventsapi/geo-rep: Geo-rep will not work without eventsapi rpms

If glusterfs-events rpm is not installed, Geo-replication will
fail since it imports eventtypes.

Any call to gsyncd will fail with Import error. Glusterd start
fails since it runs `gsyncd.py --version`

Traceback (most recent call last):
  File "/usr/libexec/glusterfs/python/syncdaemon/gsyncd.py",
    line 29, in <module>
      from syncdutils import FreeObject, norm, grabpidfile, finalize
  File "/usr/libexec/glusterfs/python/syncdaemon/syncdutils.py",
    line 28, in <module>
      from events import eventtypes
ImportError: No module named events

> Reviewed-on: http://review.gluster.org/15539
> NetBSD-regression: NetBSD Build System <jenkins@build.gluster.org>
> CentOS-regression: Gluster Build System <jenkins@build.gluster.org>
> Smoke: Gluster Build System <jenkins@build.gluster.org>
> Reviewed-by: Saravanakumar Arumugam <sarumuga@redhat.com>
> Reviewed-by: Kotresh HR <khiremat@redhat.com>

BUG: 1378030
Change-Id: I1a9bc086c3d52449ec7296cb2f9ceb16cd41a8a4
Signed-off-by: Aravinda VK <avishwan@redhat.com>
Reviewed-on: https://code.engineering.redhat.com/gerrit/85934
Reviewed-by: Atin Mukherjee <amukherj@redhat.com>
---
 geo-replication/syncdaemon/monitor.py    |    4 ++--
 geo-replication/syncdaemon/syncdutils.py |   13 ++++++++++---
 2 files changed, 12 insertions(+), 5 deletions(-)

diff --git a/geo-replication/syncdaemon/monitor.py b/geo-replication/syncdaemon/monitor.py
index a624fe4..22cd1cc 100644
--- a/geo-replication/syncdaemon/monitor.py
+++ b/geo-replication/syncdaemon/monitor.py
@@ -25,7 +25,7 @@ from gconf import gconf
 from syncdutils import select, waitpid, errno_wrap
 from syncdutils import set_term_handler, is_host_local, GsyncdError
 from syncdutils import escape, Thread, finalize, memoize
-from syncdutils import gf_event, eventtypes
+from syncdutils import gf_event, EVENT_GEOREP_FAULTY
 
 from gsyncdstatus import GeorepStatus, set_monitor_status
 
@@ -375,7 +375,7 @@ class Monitor(object):
                 ret = exit_status(ret)
                 if ret in (0, 1):
                     self.status[w[0]['dir']].set_worker_status(self.ST_FAULTY)
-                    gf_event(eventtypes.GEOREP_FAULTY,
+                    gf_event(EVENT_GEOREP_FAULTY,
                              master_volume=master.volume,
                              master_node=w[0]['host'],
                              slave_host=slave_host,
diff --git a/geo-replication/syncdaemon/syncdutils.py b/geo-replication/syncdaemon/syncdutils.py
index f5d3c51..0bcf5ec 100644
--- a/geo-replication/syncdaemon/syncdutils.py
+++ b/geo-replication/syncdaemon/syncdutils.py
@@ -25,7 +25,13 @@ from os import waitpid as owaitpid
 
 from conf import GLUSTERFS_LIBEXECDIR
 sys.path.insert(1, GLUSTERFS_LIBEXECDIR)
-from events import eventtypes
+EVENTS_ENABLED = True
+try:
+    from events.eventtypes import GEOREP_FAULTY as EVENT_GEOREP_FAULTY
+except ImportError:
+    # Events APIs not installed, dummy eventtypes with None
+    EVENTS_ENABLED = False
+    EVENT_GEOREP_FAULTY = None
 
 try:
     from cPickle import PickleError
@@ -530,5 +536,6 @@ def get_changelog_log_level(lvl):
 
 
 def gf_event(event_type, **kwargs):
-    from events.gf_event import gf_event as gfevent
-    gfevent(event_type, **kwargs)
+    if EVENTS_ENABLED:
+        from events.gf_event import gf_event as gfevent
+        gfevent(event_type, **kwargs)
-- 
1.7.1