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