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