summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorShreyas Siravara <sshreyas@fb.com>2017-09-02 22:21:16 -0700
committerShreyas Siravara <sshreyas@fb.com>2017-09-03 05:42:35 +0000
commit26776c3d21e70806237dcc02ac4bd78883416718 (patch)
tree00cba84c0d08c6aa293c3acedf78b70deac849a8
parent32d15f6911ac5aa8f0280cb3c23fc7d97e8b000f (diff)
glusterd: Log & print old clients when doing a volume set operation
Summary: - Prior to this diff, Gluster would simply log "One more more clients cannot ..." - With this diff, we now show up to 20 clients that are mismatched. - This is a port of D3313082 to 3.8 Reviewers: rwareing, kvigor Reviewed By: kvigor Change-Id: Ia8830f18c922bda1aee787a2e3d6033164bb64d4 Reviewed-on: https://review.gluster.org/18196 Reviewed-by: Shreyas Siravara <sshreyas@fb.com> CentOS-regression: Gluster Build System <jenkins@build.gluster.org> Smoke: Gluster Build System <jenkins@build.gluster.org>
-rw-r--r--libglusterfs/src/common-utils.c39
-rw-r--r--libglusterfs/src/common-utils.h3
-rw-r--r--xlators/mgmt/glusterd/src/glusterd-utils.c47
3 files changed, 79 insertions, 10 deletions
diff --git a/libglusterfs/src/common-utils.c b/libglusterfs/src/common-utils.c
index e533992556b..dbb33812287 100644
--- a/libglusterfs/src/common-utils.c
+++ b/libglusterfs/src/common-utils.c
@@ -4539,3 +4539,42 @@ gf_bits_index (uint64_t n)
{
return ffsll(n) - 1;
}
+
+
+int
+gf_peerinfo_to_hostname_and_port (const char *peerinfo, char **hostname)
+{
+ int ret = -EINVAL;
+ char *ip = NULL;
+
+ GF_VALIDATE_OR_GOTO (THIS->name, peerinfo, out);
+ GF_VALIDATE_OR_GOTO (THIS->name, hostname, out);
+
+ *hostname = NULL;
+
+ ip = strdupa (peerinfo);
+
+ char *c = strrchr (ip, ':');
+ if (!c)
+ goto err;
+
+ *c = '\0';
+
+ *hostname = gf_rev_dns_lookup (ip);
+ if (!*hostname) {
+ *hostname = gf_strdup (ip);
+ if (!*hostname) {
+ ret = -ENOMEM;
+ goto err;
+ }
+ }
+
+ ret = 0;
+ goto out;
+
+err:
+ GF_FREE (*hostname);
+ *hostname = NULL;
+out:
+ return ret;
+}
diff --git a/libglusterfs/src/common-utils.h b/libglusterfs/src/common-utils.h
index 5e338f69528..ae96c9bc1a1 100644
--- a/libglusterfs/src/common-utils.h
+++ b/libglusterfs/src/common-utils.h
@@ -846,4 +846,7 @@ gf_bits_count (uint64_t n);
int32_t
gf_bits_index (uint64_t n);
+int
+gf_peerinfo_to_hostname_and_port (const char *peerinfo, char **hostname);
+
#endif /* _COMMON_UTILS_H */
diff --git a/xlators/mgmt/glusterd/src/glusterd-utils.c b/xlators/mgmt/glusterd/src/glusterd-utils.c
index e303937579e..4224ecb2dae 100644
--- a/xlators/mgmt/glusterd/src/glusterd-utils.c
+++ b/xlators/mgmt/glusterd/src/glusterd-utils.c
@@ -11212,11 +11212,19 @@ glusterd_check_client_op_version_support (char *volname, uint32_t op_version,
xlator_t *this = NULL;
glusterd_conf_t *priv = NULL;
rpc_transport_t *xprt = NULL;
+ int print_ret = 0;
+ int num_bad_clients = 0;
+ char *bad_clients = NULL;
+ char *bad_clients_tmp = NULL;
+ char *bad_client = NULL;
+ char *last_colon = NULL;
+ char *bad_hostname = NULL;
this = THIS;
GF_ASSERT(this);
priv = this->private;
GF_ASSERT(priv);
+ gf_asprintf (&bad_clients, "\n");
pthread_mutex_lock (&priv->xprt_lock);
list_for_each_entry (xprt, &priv->xprt_list, list) {
@@ -11224,6 +11232,26 @@ glusterd_check_client_op_version_support (char *volname, uint32_t op_version,
((op_version > xprt->peerinfo.max_op_version) ||
(op_version < xprt->peerinfo.min_op_version))) {
ret = -1;
+ num_bad_clients++;
+ if (num_bad_clients <= 20) {
+ bad_clients_tmp = bad_clients;
+
+ gf_peerinfo_to_hostname_and_port (
+ xprt->peerinfo.identifier,
+ &bad_hostname);
+ if (!bad_hostname) {
+ continue;
+ }
+
+ gf_asprintf (&bad_clients,
+ "%sClient: %-40s\tMin Op Version: "
+ "%d\tMax Op Version: %d\n",
+ bad_clients_tmp, bad_hostname,
+ xprt->peerinfo.min_op_version,
+ xprt->peerinfo.max_op_version);
+
+ GF_FREE (bad_clients_tmp);
+ }
break;
}
}
@@ -11237,19 +11265,18 @@ glusterd_check_client_op_version_support (char *volname, uint32_t op_version,
"op-version %d", xprt->peerinfo.identifier,
xprt->peerinfo.min_op_version,
xprt->peerinfo.max_op_version, op_version);
- if (op_errstr)
- ret = gf_asprintf (op_errstr, "One of the client %s is "
- "running with op-version %d and "
- "doesn't support the required "
- "op-version %d. This client needs to"
- " be upgraded or disconnected "
- "before running this command again",
- xprt->peerinfo.identifier,
- xprt->peerinfo.max_op_version,
- op_version);
+ if (op_errstr) {
+ ret = gf_asprintf (op_errstr, "At least %d clients "
+ "cannot support the feature being set. "
+ "These clients need to be upgraded or "
+ "disconnected before running this command"
+ " again:\n%s", num_bad_clients, bad_clients);
+ }
+ GF_FREE (bad_clients);
return -1;
}
+ GF_FREE (bad_clients);
return 0;
}