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