1f2f23ddef
Resolves: bz#1350745 bz#1362129 bz#1541568 bz#1597252 bz#1599220 Resolves: bz#1633177 bz#1637564 bz#1639476 bz#1639568 bz#1643370 Resolves: bz#1645480 bz#1648296 bz#1648893 bz#1651040 bz#1651460 Resolves: bz#1652466 bz#1652537 bz#1653224 bz#1653613 bz#1654103 Resolves: bz#1654161 bz#1655385 bz#1655578 bz#1656357 bz#1659439 Signed-off-by: Milind Changire <mchangir@redhat.com>
224 lines
8.5 KiB
Diff
224 lines
8.5 KiB
Diff
From 1637d5018aeea96efc2916afe162c4905ef2c2d9 Mon Sep 17 00:00:00 2001
|
|
From: Ravishankar N <ravishankar@redhat.com>
|
|
Date: Fri, 14 Dec 2018 12:48:05 +0530
|
|
Subject: [PATCH 459/493] glfsheal: add a '--nolog' flag
|
|
|
|
(Upstream master patch: https://review.gluster.org/#/c/glusterfs/+/21501/)
|
|
|
|
....and if set, change the log level to GF_LOG_NONE. This is useful for
|
|
monitoring applications which invoke the heal info set of commands once
|
|
every minute, leading to un-necessary glfsheal* logs in
|
|
/var/log/glusterfs/. For example, we can now run
|
|
|
|
`gluster volume heal <VOLNAME> info --nolog`
|
|
`gluster volume heal <VOLNAME> info split-brain --nolog` etc.
|
|
|
|
The default log level is still retained at GF_LOG_INFO.
|
|
|
|
The patch also changes glfsheal internally to accept '--xml' instead of 'xml'.
|
|
Note: The --nolog flag is *not* displayed in the help anywhere, for the
|
|
sake of consistency in how the other flags are not displayed anywhere in
|
|
the help.
|
|
|
|
Change-Id: I932d0f79070880b0f9ca87e164d3c2a3b831c8c4
|
|
BUG: 1579293
|
|
Signed-off-by: Ravishankar N <ravishankar@redhat.com>
|
|
Reviewed-on: https://code.engineering.redhat.com/gerrit/158640
|
|
Tested-by: RHGS Build Bot <nigelb@redhat.com>
|
|
Reviewed-by: Sunil Kumar Heggodu Gopala Acharya <sheggodu@redhat.com>
|
|
---
|
|
cli/src/cli-cmd-volume.c | 8 ++++---
|
|
cli/src/cli.c | 5 ++++
|
|
cli/src/cli.h | 1 +
|
|
heal/src/glfs-heal.c | 59 ++++++++++++++++++++++++++++++++++++------------
|
|
4 files changed, 56 insertions(+), 17 deletions(-)
|
|
|
|
diff --git a/cli/src/cli-cmd-volume.c b/cli/src/cli-cmd-volume.c
|
|
index 32efa73..8fca7eb 100644
|
|
--- a/cli/src/cli-cmd-volume.c
|
|
+++ b/cli/src/cli-cmd-volume.c
|
|
@@ -2830,7 +2830,7 @@ cli_launch_glfs_heal (int heal_op, dict_t *options)
|
|
switch (heal_op) {
|
|
case GF_SHD_OP_INDEX_SUMMARY:
|
|
if (global_state->mode & GLUSTER_MODE_XML) {
|
|
- runner_add_args (&runner, "xml", NULL);
|
|
+ runner_add_args (&runner, "--xml", NULL);
|
|
}
|
|
break;
|
|
case GF_SHD_OP_SBRAIN_HEAL_FROM_BIGGER_FILE:
|
|
@@ -2854,7 +2854,7 @@ cli_launch_glfs_heal (int heal_op, dict_t *options)
|
|
case GF_SHD_OP_SPLIT_BRAIN_FILES:
|
|
runner_add_args (&runner, "split-brain-info", NULL);
|
|
if (global_state->mode & GLUSTER_MODE_XML) {
|
|
- runner_add_args (&runner, "xml", NULL);
|
|
+ runner_add_args (&runner, "--xml", NULL);
|
|
}
|
|
break;
|
|
case GF_SHD_OP_GRANULAR_ENTRY_HEAL_ENABLE:
|
|
@@ -2864,12 +2864,14 @@ cli_launch_glfs_heal (int heal_op, dict_t *options)
|
|
case GF_SHD_OP_HEAL_SUMMARY:
|
|
runner_add_args (&runner, "info-summary", NULL);
|
|
if (global_state->mode & GLUSTER_MODE_XML) {
|
|
- runner_add_args (&runner, "xml", NULL);
|
|
+ runner_add_args (&runner, "--xml", NULL);
|
|
}
|
|
break;
|
|
default:
|
|
ret = -1;
|
|
}
|
|
+ if (global_state->mode & GLUSTER_MODE_GLFSHEAL_NOLOG)
|
|
+ runner_add_args(&runner, "--nolog", NULL);
|
|
ret = runner_start (&runner);
|
|
if (ret == -1)
|
|
goto out;
|
|
diff --git a/cli/src/cli.c b/cli/src/cli.c
|
|
index b64d4ef..3fd7bc5 100644
|
|
--- a/cli/src/cli.c
|
|
+++ b/cli/src/cli.c
|
|
@@ -340,6 +340,11 @@ cli_opt_parse (char *opt, struct cli_state *state)
|
|
return 0;
|
|
}
|
|
|
|
+ if (strcmp(opt, "nolog") == 0) {
|
|
+ state->mode |= GLUSTER_MODE_GLFSHEAL_NOLOG;
|
|
+ return 0;
|
|
+ }
|
|
+
|
|
if (strcmp (opt, "wignore-partition") == 0) {
|
|
state->mode |= GLUSTER_MODE_WIGNORE_PARTITION;
|
|
return 0;
|
|
diff --git a/cli/src/cli.h b/cli/src/cli.h
|
|
index 109dcd4..104d601 100644
|
|
--- a/cli/src/cli.h
|
|
+++ b/cli/src/cli.h
|
|
@@ -61,6 +61,7 @@ typedef enum {
|
|
#define GLUSTER_MODE_XML (1 << 2)
|
|
#define GLUSTER_MODE_WIGNORE (1 << 3)
|
|
#define GLUSTER_MODE_WIGNORE_PARTITION (1 << 4)
|
|
+#define GLUSTER_MODE_GLFSHEAL_NOLOG (1 << 5)
|
|
|
|
|
|
#define GLUSTERD_GET_QUOTA_LIST_MOUNT_PATH(abspath, volname, path) do { \
|
|
diff --git a/heal/src/glfs-heal.c b/heal/src/glfs-heal.c
|
|
index 153cd29..12746dc 100644
|
|
--- a/heal/src/glfs-heal.c
|
|
+++ b/heal/src/glfs-heal.c
|
|
@@ -40,6 +40,9 @@ xmlDocPtr glfsh_doc = NULL;
|
|
ret = 0; \
|
|
} while (0) \
|
|
|
|
+#define MODE_XML (1 << 0)
|
|
+#define MODE_NO_LOG (1 << 1)
|
|
+
|
|
typedef struct num_entries {
|
|
uint64_t num_entries;
|
|
uint64_t pending_entries;
|
|
@@ -1434,6 +1437,28 @@ out:
|
|
return ret;
|
|
}
|
|
|
|
+static void
|
|
+parse_flags(int *argc, char **argv, int *flags)
|
|
+{
|
|
+ int i = 0;
|
|
+ char *opt = NULL;
|
|
+ int count = 0;
|
|
+
|
|
+ for (i = 0; i < *argc; i++) {
|
|
+ opt = strtail(argv[i], "--");
|
|
+ if (!opt)
|
|
+ continue;
|
|
+ if (strcmp(opt, "nolog") == 0) {
|
|
+ *flags |= MODE_NO_LOG;
|
|
+ count++;
|
|
+ } else if (strcmp(opt, "xml") == 0) {
|
|
+ *flags |= MODE_XML;
|
|
+ count++;
|
|
+ }
|
|
+ }
|
|
+ *argc = *argc - count;
|
|
+}
|
|
+
|
|
int
|
|
glfsh_heal_from_bigger_file_or_mtime (glfs_t *fs, xlator_t *top_subvol,
|
|
loc_t *rootloc, char *file,
|
|
@@ -1518,6 +1543,8 @@ main (int argc, char **argv)
|
|
char *file = NULL;
|
|
char *op_errstr = NULL;
|
|
gf_xl_afr_op_t heal_op = -1;
|
|
+ gf_loglevel_t log_level = GF_LOG_INFO;
|
|
+ int flags = 0;
|
|
|
|
if (argc < 2) {
|
|
printf (USAGE_STR, argv[0]);
|
|
@@ -1526,6 +1553,13 @@ main (int argc, char **argv)
|
|
}
|
|
|
|
volname = argv[1];
|
|
+
|
|
+ parse_flags(&argc, argv, &flags);
|
|
+ if (flags & MODE_NO_LOG)
|
|
+ log_level = GF_LOG_NONE;
|
|
+ if (flags & MODE_XML)
|
|
+ is_xml = 1;
|
|
+
|
|
switch (argc) {
|
|
case 2:
|
|
heal_op = GF_SHD_OP_INDEX_SUMMARY;
|
|
@@ -1533,9 +1567,6 @@ main (int argc, char **argv)
|
|
case 3:
|
|
if (!strcmp (argv[2], "split-brain-info")) {
|
|
heal_op = GF_SHD_OP_SPLIT_BRAIN_FILES;
|
|
- } else if (!strcmp (argv[2], "xml")) {
|
|
- heal_op = GF_SHD_OP_INDEX_SUMMARY;
|
|
- is_xml = 1;
|
|
} else if (!strcmp (argv[2], "granular-entry-heal-op")) {
|
|
heal_op = GF_SHD_OP_GRANULAR_ENTRY_HEAL_ENABLE;
|
|
} else if (!strcmp (argv[2], "info-summary")) {
|
|
@@ -1547,15 +1578,7 @@ main (int argc, char **argv)
|
|
}
|
|
break;
|
|
case 4:
|
|
- if ((!strcmp (argv[2], "split-brain-info"))
|
|
- && (!strcmp (argv[3], "xml"))) {
|
|
- heal_op = GF_SHD_OP_SPLIT_BRAIN_FILES;
|
|
- is_xml = 1;
|
|
- } else if ((!strcmp (argv[2], "info-summary"))
|
|
- && (!strcmp (argv[3], "xml"))) {
|
|
- heal_op = GF_SHD_OP_HEAL_SUMMARY;
|
|
- is_xml = 1;
|
|
- } else if (!strcmp (argv[2], "bigger-file")) {
|
|
+ if (!strcmp (argv[2], "bigger-file")) {
|
|
heal_op = GF_SHD_OP_SBRAIN_HEAL_FROM_BIGGER_FILE;
|
|
file = argv[3];
|
|
} else if (!strcmp (argv[2], "latest-mtime")) {
|
|
@@ -1592,7 +1615,15 @@ main (int argc, char **argv)
|
|
glfsh_output = &glfsh_human_readable;
|
|
if (is_xml) {
|
|
#if (HAVE_LIB_XML)
|
|
- glfsh_output = &glfsh_xml_output;
|
|
+ if ((heal_op == GF_SHD_OP_INDEX_SUMMARY) ||
|
|
+ (heal_op == GF_SHD_OP_SPLIT_BRAIN_FILES) ||
|
|
+ (heal_op == GF_SHD_OP_HEAL_SUMMARY)) {
|
|
+ glfsh_output = &glfsh_xml_output;
|
|
+ } else {
|
|
+ printf(USAGE_STR, argv[0]);
|
|
+ ret = -1;
|
|
+ goto out;
|
|
+ }
|
|
#else
|
|
/*No point doing anything, just fail the command*/
|
|
exit (EXIT_FAILURE);
|
|
@@ -1636,7 +1667,7 @@ main (int argc, char **argv)
|
|
}
|
|
snprintf (logfilepath, sizeof (logfilepath),
|
|
DEFAULT_HEAL_LOG_FILE_DIRECTORY"/glfsheal-%s.log", volname);
|
|
- ret = glfs_set_logging(fs, logfilepath, GF_LOG_INFO);
|
|
+ ret = glfs_set_logging(fs, logfilepath, log_level);
|
|
if (ret < 0) {
|
|
ret = -errno;
|
|
gf_asprintf (&op_errstr, "Failed to set the log file path, "
|
|
--
|
|
1.8.3.1
|
|
|