e3c68b
From f38f0988eb6c0d72677abceba5ebeb51ea8d44ad Mon Sep 17 00:00:00 2001
e3c68b
From: Mohit Agrawal <moagrawal@redhat.com>
e3c68b
Date: Tue, 21 Jan 2020 21:09:56 +0530
e3c68b
Subject: [PATCH 351/351] server: Mount fails after reboot 1/3 gluster nodes
e3c68b
e3c68b
Problem: At the time of coming up one server node(1x3) after reboot
e3c68b
client is unmounted.The client is unmounted because a client
e3c68b
is getting AUTH_FAILED event and client call fini for the graph.The
e3c68b
client is getting AUTH_FAILED because brick is not attached with a
e3c68b
graph at that moment
e3c68b
e3c68b
Solution: To avoid the unmounting the client graph throw ENOENT error
e3c68b
          from server in case if brick is not attached with server at
e3c68b
          the time of authenticate clients.
e3c68b
e3c68b
> Credits: Xavi Hernandez <xhernandez@redhat.com>
e3c68b
> Change-Id: Ie6fbd73cbcf23a35d8db8841b3b6036e87682f5e
e3c68b
> Fixes: bz#1793852
e3c68b
> Signed-off-by: Mohit Agrawal <moagrawa@redhat.com>
e3c68b
> (Cherry picked from commit e4f776308d5ee7ffeb07de0fd9e1edae6944030d)
e3c68b
> (Reviewd on upstream link https://review.gluster.org/#/c/glusterfs/+/24053/)
e3c68b
e3c68b
Change-Id: Ie6fbd73cbcf23a35d8db8841b3b6036e87682f5e
e3c68b
BUG: 1793035
e3c68b
Signed-off-by: Mohit Agrawal <moagrawa@redhat.com>
e3c68b
Reviewed-on: https://code.engineering.redhat.com/gerrit/190042
e3c68b
Tested-by: RHGS Build Bot <nigelb@redhat.com>
e3c68b
Reviewed-by: Sunil Kumar Heggodu Gopala Acharya <sheggodu@redhat.com>
e3c68b
---
e3c68b
 tests/bugs/protocol/bug-1433815-auth-allow.t   |  1 +
e3c68b
 xlators/protocol/client/src/client-handshake.c |  3 +-
e3c68b
 xlators/protocol/server/src/server-handshake.c | 41 +++++++++++++++++---------
e3c68b
 3 files changed, 29 insertions(+), 16 deletions(-)
e3c68b
e3c68b
diff --git a/tests/bugs/protocol/bug-1433815-auth-allow.t b/tests/bugs/protocol/bug-1433815-auth-allow.t
e3c68b
index fa22ad8..a78c0eb 100644
e3c68b
--- a/tests/bugs/protocol/bug-1433815-auth-allow.t
e3c68b
+++ b/tests/bugs/protocol/bug-1433815-auth-allow.t
e3c68b
@@ -17,6 +17,7 @@ TEST $CLI volume create $V0 $H0:$B0/$V0
e3c68b
 # Set auth.allow so it *doesn't* include ourselves.
e3c68b
 TEST $CLI volume set $V0 auth.allow 1.2.3.4
e3c68b
 TEST $CLI volume start $V0
e3c68b
+EXPECT_WITHIN $CHILD_UP_TIMEOUT "1" online_brick_count
e3c68b
 
e3c68b
 # "System getspec" will include the username and password if the request comes
e3c68b
 # from a server (which we are).  Unfortunately, this will cause authentication
e3c68b
diff --git a/xlators/protocol/client/src/client-handshake.c b/xlators/protocol/client/src/client-handshake.c
e3c68b
index c43756a..0002361 100644
e3c68b
--- a/xlators/protocol/client/src/client-handshake.c
e3c68b
+++ b/xlators/protocol/client/src/client-handshake.c
e3c68b
@@ -1031,8 +1031,7 @@ client_setvolume_cbk(struct rpc_req *req, struct iovec *iov, int count,
e3c68b
                "SETVOLUME on remote-host failed: %s", remote_error);
e3c68b
 
e3c68b
         errno = op_errno;
e3c68b
-        if (remote_error &&
e3c68b
-            (strcmp("Authentication failed", remote_error) == 0)) {
e3c68b
+        if (remote_error && (op_errno == EACCES)) {
e3c68b
             auth_fail = _gf_true;
e3c68b
             op_ret = 0;
e3c68b
         }
e3c68b
diff --git a/xlators/protocol/server/src/server-handshake.c b/xlators/protocol/server/src/server-handshake.c
e3c68b
index 382f241..1d1177d 100644
e3c68b
--- a/xlators/protocol/server/src/server-handshake.c
e3c68b
+++ b/xlators/protocol/server/src/server-handshake.c
e3c68b
@@ -250,6 +250,7 @@ server_setvolume(rpcsvc_request_t *req)
e3c68b
     char *subdir_mount = NULL;
e3c68b
     char *client_name = NULL;
e3c68b
     gf_boolean_t cleanup_starting = _gf_false;
e3c68b
+    gf_boolean_t xlator_in_graph = _gf_true;
e3c68b
 
e3c68b
     params = dict_new();
e3c68b
     reply = dict_new();
e3c68b
@@ -311,8 +312,10 @@ server_setvolume(rpcsvc_request_t *req)
e3c68b
     LOCK(&ctx->volfile_lock);
e3c68b
     {
e3c68b
         xl = get_xlator_by_name(this, name);
e3c68b
-        if (!xl)
e3c68b
+        if (!xl) {
e3c68b
+            xlator_in_graph = _gf_false;
e3c68b
             xl = this;
e3c68b
+        }
e3c68b
     }
e3c68b
     UNLOCK(&ctx->volfile_lock);
e3c68b
     if (xl == NULL) {
e3c68b
@@ -568,20 +571,30 @@ server_setvolume(rpcsvc_request_t *req)
e3c68b
                          "failed to set error "
e3c68b
                          "msg");
e3c68b
     } else {
e3c68b
-        gf_event(EVENT_CLIENT_AUTH_REJECT,
e3c68b
-                 "client_uid=%s;"
e3c68b
-                 "client_identifier=%s;server_identifier=%s;"
e3c68b
-                 "brick_path=%s",
e3c68b
-                 client->client_uid, req->trans->peerinfo.identifier,
e3c68b
-                 req->trans->myinfo.identifier, name);
e3c68b
-        gf_msg(this->name, GF_LOG_ERROR, EACCES, PS_MSG_AUTHENTICATE_ERROR,
e3c68b
-               "Cannot authenticate client"
e3c68b
-               " from %s %s",
e3c68b
-               client->client_uid, (clnt_version) ? clnt_version : "old");
e3c68b
-
e3c68b
         op_ret = -1;
e3c68b
-        op_errno = EACCES;
e3c68b
-        ret = dict_set_str(reply, "ERROR", "Authentication failed");
e3c68b
+        if (!xlator_in_graph) {
e3c68b
+            gf_msg(this->name, GF_LOG_ERROR, ENOENT, PS_MSG_AUTHENTICATE_ERROR,
e3c68b
+                   "Cannot authenticate client"
e3c68b
+                   " from %s %s because brick is not attached in graph",
e3c68b
+                   client->client_uid, (clnt_version) ? clnt_version : "old");
e3c68b
+
e3c68b
+            op_errno = ENOENT;
e3c68b
+            ret = dict_set_str(reply, "ERROR", "Brick not found");
e3c68b
+        } else {
e3c68b
+            gf_event(EVENT_CLIENT_AUTH_REJECT,
e3c68b
+                     "client_uid=%s;"
e3c68b
+                     "client_identifier=%s;server_identifier=%s;"
e3c68b
+                     "brick_path=%s",
e3c68b
+                     client->client_uid, req->trans->peerinfo.identifier,
e3c68b
+                     req->trans->myinfo.identifier, name);
e3c68b
+            gf_msg(this->name, GF_LOG_ERROR, EACCES, PS_MSG_AUTHENTICATE_ERROR,
e3c68b
+                   "Cannot authenticate client"
e3c68b
+                   " from %s %s",
e3c68b
+                   client->client_uid, (clnt_version) ? clnt_version : "old");
e3c68b
+
e3c68b
+            op_errno = EACCES;
e3c68b
+            ret = dict_set_str(reply, "ERROR", "Authentication failed");
e3c68b
+        }
e3c68b
         if (ret < 0)
e3c68b
             gf_msg_debug(this->name, 0,
e3c68b
                          "failed to set error "
e3c68b
-- 
e3c68b
1.8.3.1
e3c68b