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