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