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