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