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