d2787b
From 9b19d4841fc3002d30ec3e44c85ec37682c11bfb Mon Sep 17 00:00:00 2001
d2787b
From: schaffung <ssivakum@redhat.com>
d2787b
Date: Thu, 22 Oct 2020 13:07:09 +0530
d2787b
Subject: [PATCH 486/511] glusterd: brick sock file deleted, log error (#1560)
d2787b
d2787b
Issue: The satus of the brick as tracked by glusterd is
d2787b
stopped if the socket file corresponding to a running
d2787b
brick process is absent in /var/run/gluster. The glusterd
d2787b
keeps on trying to reconnect ( rpc layer ) but it fails.
d2787b
d2787b
Code change: Rather than registering the rpc connection
d2787b
with the help of the given sockfilepath which is not
d2787b
even present as it keeps on reconnecting, why not log
d2787b
this as an error and not try to reconnect using the
d2787b
non-existing sock file path.
d2787b
d2787b
>Fixes: #1526
d2787b
>Change-Id: I6c81691ab1624c66dec74f5ffcc6c383201ac757
d2787b
>Signed-off-by: srijan-sivakumar <ssivakumar@redhat.com>
d2787b
Upstream Patch : https://github.com/gluster/glusterfs/pull/1560
d2787b
d2787b
BUG: 1882923
d2787b
Change-Id: I6c81691ab1624c66dec74f5ffcc6c383201ac757
d2787b
Signed-off-by: Srijan Sivakumar <ssivakum@redhat.com>
d2787b
Reviewed-on: https://code.engineering.redhat.com/gerrit/220376
d2787b
Tested-by: RHGS Build Bot <nigelb@redhat.com>
d2787b
Reviewed-by: Sunil Kumar Heggodu Gopala Acharya <sheggodu@redhat.com>
d2787b
---
d2787b
 xlators/mgmt/glusterd/src/glusterd-utils.c | 27 +++++++++++++++++++++++++--
d2787b
 1 file changed, 25 insertions(+), 2 deletions(-)
d2787b
d2787b
diff --git a/xlators/mgmt/glusterd/src/glusterd-utils.c b/xlators/mgmt/glusterd/src/glusterd-utils.c
d2787b
index d25fc8a..a72c494 100644
d2787b
--- a/xlators/mgmt/glusterd/src/glusterd-utils.c
d2787b
+++ b/xlators/mgmt/glusterd/src/glusterd-utils.c
d2787b
@@ -6310,7 +6310,7 @@ find_compatible_brick(glusterd_conf_t *conf, glusterd_volinfo_t *volinfo,
d2787b
    check if passed pid is match with running  glusterfs process
d2787b
 */
d2787b
 
d2787b
-int
d2787b
+static int
d2787b
 glusterd_get_sock_from_brick_pid(int pid, char *sockpath, size_t len)
d2787b
 {
d2787b
     char fname[128] = "";
d2787b
@@ -6383,7 +6383,17 @@ glusterd_get_sock_from_brick_pid(int pid, char *sockpath, size_t len)
d2787b
 
d2787b
     if (tmpsockpath[0]) {
d2787b
         strncpy(sockpath, tmpsockpath, i);
d2787b
-        ret = 0;
d2787b
+        /*
d2787b
+         * Condition to check if the brick socket file is present
d2787b
+         * in the stated path or not. This helps in preventing
d2787b
+         * constant re-connect triggered in the RPC layer and also
d2787b
+         * a log message would help out the user.
d2787b
+         */
d2787b
+        ret = sys_access(sockpath, F_OK);
d2787b
+        if (ret) {
d2787b
+            gf_smsg(this->name, GF_LOG_ERROR, 0, GD_MSG_FILE_NOT_FOUND,
d2787b
+                    "%s not found", sockpath, NULL);
d2787b
+        }
d2787b
     }
d2787b
 
d2787b
     return ret;
d2787b
@@ -6581,7 +6591,20 @@ glusterd_brick_start(glusterd_volinfo_t *volinfo,
d2787b
             if (!is_brick_mx_enabled()) {
d2787b
                 glusterd_set_brick_socket_filepath(
d2787b
                     volinfo, brickinfo, socketpath, sizeof(socketpath));
d2787b
+                /*
d2787b
+                 * Condition to check if the brick socket file is present
d2787b
+                 * in the stated path or not. This helps in preventing
d2787b
+                 * constant re-connect triggered in the RPC layer and also
d2787b
+                 * a log message would help out the user.
d2787b
+                 */
d2787b
+                ret = sys_access(socketpath, F_OK);
d2787b
+                if (ret) {
d2787b
+                    gf_smsg(this->name, GF_LOG_ERROR, 0, GD_MSG_FILE_NOT_FOUND,
d2787b
+                            "%s not found", socketpath, NULL);
d2787b
+                    goto out;
d2787b
+                }
d2787b
             }
d2787b
+
d2787b
             gf_log(this->name, GF_LOG_DEBUG,
d2787b
                    "Using %s as sockfile for brick %s of volume %s ",
d2787b
                    socketpath, brickinfo->path, volinfo->volname);
d2787b
-- 
d2787b
1.8.3.1
d2787b