|
|
887953 |
From 1a24a7942fe9ecccaf29ae9bc125cd9b08fc8906 Mon Sep 17 00:00:00 2001
|
|
|
887953 |
From: karthik-us <ksubrahm@redhat.com>
|
|
|
887953 |
Date: Mon, 5 Nov 2018 17:57:55 +0530
|
|
|
887953 |
Subject: [PATCH 417/444] cli: Add warning message while converting to replica
|
|
|
887953 |
2 configuration
|
|
|
887953 |
|
|
|
887953 |
Backport of: https://review.gluster.org/#/c/glusterfs/+/21136/
|
|
|
887953 |
|
|
|
887953 |
Currently while creating replica 2 volume we display a warning message
|
|
|
887953 |
of ending up in split-brain. But while converting an existing volume
|
|
|
887953 |
from other configuration to replica 2 by add-brick or remove-brick
|
|
|
887953 |
operations we do not show any such messages.
|
|
|
887953 |
With this fix in add-brick and remove-brick cases also we will display
|
|
|
887953 |
the same warning message and prompt for confirmation if the configuration
|
|
|
887953 |
changes to replica 2.
|
|
|
887953 |
|
|
|
887953 |
Change-Id: Id7b1a40e80fca3e1043b802fa5f7c3b656ef2228
|
|
|
887953 |
BUG: 1579758
|
|
|
887953 |
Signed-off-by: karthik-us <ksubrahm@redhat.com>
|
|
|
887953 |
Reviewed-on: https://code.engineering.redhat.com/gerrit/154947
|
|
|
887953 |
Tested-by: RHGS Build Bot <nigelb@redhat.com>
|
|
|
887953 |
Reviewed-by: Ravishankar Narayanankutty <ravishankar@redhat.com>
|
|
|
887953 |
Reviewed-by: Atin Mukherjee <amukherj@redhat.com>
|
|
|
887953 |
---
|
|
|
887953 |
cli/src/cli-cmd-parser.c | 48 +++++++++++++++++++++++++++++++++++++++++++-----
|
|
|
887953 |
cli/src/cli-cmd-volume.c | 11 +++++++----
|
|
|
887953 |
cli/src/cli.h | 10 +++++-----
|
|
|
887953 |
3 files changed, 55 insertions(+), 14 deletions(-)
|
|
|
887953 |
|
|
|
887953 |
diff --git a/cli/src/cli-cmd-parser.c b/cli/src/cli-cmd-parser.c
|
|
|
887953 |
index 7917d66..3745fb4 100644
|
|
|
887953 |
--- a/cli/src/cli-cmd-parser.c
|
|
|
887953 |
+++ b/cli/src/cli-cmd-parser.c
|
|
|
887953 |
@@ -1774,8 +1774,8 @@ out:
|
|
|
887953 |
}
|
|
|
887953 |
|
|
|
887953 |
int32_t
|
|
|
887953 |
-cli_cmd_volume_add_brick_parse (const char **words, int wordcount,
|
|
|
887953 |
- dict_t **options, int *ret_type)
|
|
|
887953 |
+cli_cmd_volume_add_brick_parse (struct cli_state *state, const char **words,
|
|
|
887953 |
+ int wordcount, dict_t **options, int *ret_type)
|
|
|
887953 |
{
|
|
|
887953 |
dict_t *dict = NULL;
|
|
|
887953 |
char *volname = NULL;
|
|
|
887953 |
@@ -1790,6 +1790,8 @@ cli_cmd_volume_add_brick_parse (const char **words, int wordcount,
|
|
|
887953 |
int index;
|
|
|
887953 |
gf_boolean_t is_force = _gf_false;
|
|
|
887953 |
int wc = wordcount;
|
|
|
887953 |
+ gf_answer_t answer = GF_ANSWER_NO;
|
|
|
887953 |
+ const char *question = NULL;
|
|
|
887953 |
|
|
|
887953 |
GF_ASSERT (words);
|
|
|
887953 |
GF_ASSERT (options);
|
|
|
887953 |
@@ -1854,6 +1856,23 @@ cli_cmd_volume_add_brick_parse (const char **words, int wordcount,
|
|
|
887953 |
goto out;
|
|
|
887953 |
index = 7;
|
|
|
887953 |
}
|
|
|
887953 |
+
|
|
|
887953 |
+ if (count == 2) {
|
|
|
887953 |
+ if (strcmp (words[wordcount - 1], "force")) {
|
|
|
887953 |
+ question = "Replica 2 volumes are prone to "
|
|
|
887953 |
+ "split-brain. Use Arbiter or "
|
|
|
887953 |
+ "Replica 3 to avoid this.\n"
|
|
|
887953 |
+ "Do you still want to continue?\n";
|
|
|
887953 |
+ answer = cli_cmd_get_confirmation (state,
|
|
|
887953 |
+ question);
|
|
|
887953 |
+ if (GF_ANSWER_NO == answer) {
|
|
|
887953 |
+ gf_log ("cli", GF_LOG_ERROR, "Add brick"
|
|
|
887953 |
+ " cancelled, exiting");
|
|
|
887953 |
+ ret = -1;
|
|
|
887953 |
+ goto out;
|
|
|
887953 |
+ }
|
|
|
887953 |
+ }
|
|
|
887953 |
+ }
|
|
|
887953 |
} else if ((strcmp (w, "stripe")) == 0) {
|
|
|
887953 |
type = GF_CLUSTER_TYPE_STRIPE;
|
|
|
887953 |
count = strtol (words[4], NULL, 0);
|
|
|
887953 |
@@ -2061,9 +2080,9 @@ out:
|
|
|
887953 |
}
|
|
|
887953 |
|
|
|
887953 |
int32_t
|
|
|
887953 |
-cli_cmd_volume_remove_brick_parse (const char **words, int wordcount,
|
|
|
887953 |
- dict_t **options, int *question,
|
|
|
887953 |
- int *brick_count)
|
|
|
887953 |
+cli_cmd_volume_remove_brick_parse (struct cli_state *state, const char **words,
|
|
|
887953 |
+ int wordcount, dict_t **options,
|
|
|
887953 |
+ int *question, int *brick_count)
|
|
|
887953 |
{
|
|
|
887953 |
dict_t *dict = NULL;
|
|
|
887953 |
char *volname = NULL;
|
|
|
887953 |
@@ -2081,6 +2100,8 @@ cli_cmd_volume_remove_brick_parse (const char **words, int wordcount,
|
|
|
887953 |
char *w = NULL;
|
|
|
887953 |
int32_t command = GF_OP_CMD_NONE;
|
|
|
887953 |
long count = 0;
|
|
|
887953 |
+ gf_answer_t answer = GF_ANSWER_NO;
|
|
|
887953 |
+ const char *ques = NULL;
|
|
|
887953 |
|
|
|
887953 |
GF_ASSERT (words);
|
|
|
887953 |
GF_ASSERT (options);
|
|
|
887953 |
@@ -2115,6 +2136,23 @@ cli_cmd_volume_remove_brick_parse (const char **words, int wordcount,
|
|
|
887953 |
goto out;
|
|
|
887953 |
}
|
|
|
887953 |
|
|
|
887953 |
+ if (count == 2) {
|
|
|
887953 |
+ if (strcmp (words[wordcount - 1], "force")) {
|
|
|
887953 |
+ ques = "Replica 2 volumes are prone to "
|
|
|
887953 |
+ "split-brain. Use Arbiter or Replica 3 "
|
|
|
887953 |
+ "to avoid this.\n"
|
|
|
887953 |
+ "Do you still want to continue?\n";
|
|
|
887953 |
+ answer = cli_cmd_get_confirmation (state,
|
|
|
887953 |
+ ques);
|
|
|
887953 |
+ if (GF_ANSWER_NO == answer) {
|
|
|
887953 |
+ gf_log ("cli", GF_LOG_ERROR, "Remove "
|
|
|
887953 |
+ "brick cancelled, exiting");
|
|
|
887953 |
+ ret = -1;
|
|
|
887953 |
+ goto out;
|
|
|
887953 |
+ }
|
|
|
887953 |
+ }
|
|
|
887953 |
+ }
|
|
|
887953 |
+
|
|
|
887953 |
ret = dict_set_int32 (dict, "replica-count", count);
|
|
|
887953 |
if (ret)
|
|
|
887953 |
goto out;
|
|
|
887953 |
diff --git a/cli/src/cli-cmd-volume.c b/cli/src/cli-cmd-volume.c
|
|
|
887953 |
index a1f0840..32efa73 100644
|
|
|
887953 |
--- a/cli/src/cli-cmd-volume.c
|
|
|
887953 |
+++ b/cli/src/cli-cmd-volume.c
|
|
|
887953 |
@@ -1021,7 +1021,8 @@ cli_cmd_volume_add_brick_cbk (struct cli_state *state,
|
|
|
887953 |
if (!frame)
|
|
|
887953 |
goto out;
|
|
|
887953 |
|
|
|
887953 |
- ret = cli_cmd_volume_add_brick_parse (words, wordcount, &options, 0);
|
|
|
887953 |
+ ret = cli_cmd_volume_add_brick_parse (state, words, wordcount, &options,
|
|
|
887953 |
+ 0);
|
|
|
887953 |
if (ret) {
|
|
|
887953 |
cli_usage_out (word->pattern);
|
|
|
887953 |
parse_error = 1;
|
|
|
887953 |
@@ -1151,7 +1152,8 @@ do_cli_cmd_volume_attach_tier (struct cli_state *state,
|
|
|
887953 |
if (!frame)
|
|
|
887953 |
goto out;
|
|
|
887953 |
|
|
|
887953 |
- ret = cli_cmd_volume_add_brick_parse (words, wordcount, &options, &type);
|
|
|
887953 |
+ ret = cli_cmd_volume_add_brick_parse (state, words, wordcount, &options,
|
|
|
887953 |
+ &type);
|
|
|
887953 |
if (ret) {
|
|
|
887953 |
cli_usage_out (word->pattern);
|
|
|
887953 |
parse_error = 1;
|
|
|
887953 |
@@ -2032,8 +2034,9 @@ cli_cmd_volume_remove_brick_cbk (struct cli_state *state,
|
|
|
887953 |
if (!frame)
|
|
|
887953 |
goto out;
|
|
|
887953 |
|
|
|
887953 |
- ret = cli_cmd_volume_remove_brick_parse (words, wordcount, &options,
|
|
|
887953 |
- &need_question, &brick_count);
|
|
|
887953 |
+ ret = cli_cmd_volume_remove_brick_parse (state, words, wordcount,
|
|
|
887953 |
+ &options, &need_question,
|
|
|
887953 |
+ &brick_count);
|
|
|
887953 |
if (ret) {
|
|
|
887953 |
cli_usage_out (word->pattern);
|
|
|
887953 |
parse_error = 1;
|
|
|
887953 |
diff --git a/cli/src/cli.h b/cli/src/cli.h
|
|
|
887953 |
index c9bf93d..109dcd4 100644
|
|
|
887953 |
--- a/cli/src/cli.h
|
|
|
887953 |
+++ b/cli/src/cli.h
|
|
|
887953 |
@@ -264,8 +264,8 @@ cli_cmd_get_state_parse (struct cli_state *state, const char **words,
|
|
|
887953 |
int wordcount, dict_t **options, char **op_errstr);
|
|
|
887953 |
|
|
|
887953 |
int32_t
|
|
|
887953 |
-cli_cmd_volume_add_brick_parse (const char **words, int wordcount,
|
|
|
887953 |
- dict_t **options, int *type);
|
|
|
887953 |
+cli_cmd_volume_add_brick_parse (struct cli_state *state, const char **words,
|
|
|
887953 |
+ int wordcount, dict_t **options, int *type);
|
|
|
887953 |
|
|
|
887953 |
int32_t
|
|
|
887953 |
cli_cmd_volume_detach_tier_parse (const char **words, int wordcount,
|
|
|
887953 |
@@ -280,9 +280,9 @@ cli_cmd_volume_old_tier_parse (const char **words, int wordcount,
|
|
|
887953 |
dict_t **options);
|
|
|
887953 |
|
|
|
887953 |
int32_t
|
|
|
887953 |
-cli_cmd_volume_remove_brick_parse (const char **words, int wordcount,
|
|
|
887953 |
- dict_t **options, int *question,
|
|
|
887953 |
- int *brick_count);
|
|
|
887953 |
+cli_cmd_volume_remove_brick_parse (struct cli_state *state, const char **words,
|
|
|
887953 |
+ int wordcount, dict_t **options,
|
|
|
887953 |
+ int *question, int *brick_count);
|
|
|
887953 |
|
|
|
887953 |
int32_t
|
|
|
887953 |
cli_cmd_volume_replace_brick_parse (const char **words, int wordcount,
|
|
|
887953 |
--
|
|
|
887953 |
1.8.3.1
|
|
|
887953 |
|