Blob Blame History Raw
From 69988283af0e8692ebbbc581fae23e8150c8e85d Mon Sep 17 00:00:00 2001
From: Aravinda VK <avishwan@redhat.com>
Date: Wed, 7 Sep 2016 11:39:39 +0530
Subject: [PATCH 81/86] geo-rep: Fix Geo-rep status if monitor.pid file not exists

If monitor.pid file not exists, gsyncd fails with following traceback

Traceback (most recent call last):
  File "/usr/libexec/glusterfs/python/syncdaemon/gsyncd.py",
  line 201, in main
    main_i()
  File "/usr/libexec/glusterfs/python/syncdaemon/gsyncd.py",
  line 681, in main_i
    brick_status.print_status(checkpoint_time=checkpoint_time)
  File "/usr/libexec/glusterfs/python/syncdaemon/gsyncdstatus.py",
  line 343, in print_status
    for key, value in self.get_status(checkpoint_time).items():
  File "/usr/libexec/glusterfs/python/syncdaemon/gsyncdstatus.py",
  line 262, in get_status
    with open(self.monitor_pid_file, "r+") as f:
IOError: [Errno 2] No such file or directory: '/var/lib/glusterd/
  geo-replication/master_node_slave/monitor.pid'

If Georep status command this worker's status will not be displayed
since not returning expected status output.

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

BUG: 1369384
Change-Id: I600a2f5d9617f993d635b9bc6e393108500db5f9
Signed-off-by: Aravinda VK <avishwan@redhat.com>
Reviewed-on: https://code.engineering.redhat.com/gerrit/85005
Reviewed-by: Atin Mukherjee <amukherj@redhat.com>
---
 geo-replication/syncdaemon/gsyncdstatus.py |    8 ++++++--
 1 files changed, 6 insertions(+), 2 deletions(-)

diff --git a/geo-replication/syncdaemon/gsyncdstatus.py b/geo-replication/syncdaemon/gsyncdstatus.py
index 88398e2..f4d50c1 100644
--- a/geo-replication/syncdaemon/gsyncdstatus.py
+++ b/geo-replication/syncdaemon/gsyncdstatus.py
@@ -16,7 +16,7 @@ import urllib
 import json
 import time
 from datetime import datetime
-from errno import EACCES, EAGAIN
+from errno import EACCES, EAGAIN, ENOENT
 
 DEFAULT_STATUS = "N/A"
 MONITOR_STATUS = ("Created", "Started", "Paused", "Stopped")
@@ -263,7 +263,11 @@ class GeorepStatus(object):
                     fcntl.lockf(f, fcntl.LOCK_EX | fcntl.LOCK_NB)
                     monitor_status = "Stopped"
             except (IOError, OSError) as e:
-                if e.errno in (EACCES, EAGAIN):
+                # If pid file not exists, either monitor died or Geo-rep
+                # not even started once
+                if e.errno == ENOENT:
+                    monitor_status = "Stopped"
+                elif e.errno in (EACCES, EAGAIN):
                     # cannot grab. so, monitor process still running..move on
                     pass
                 else:
-- 
1.7.1