diff options
author | Susant Palai <spalai@redhat.com> | 2018-02-26 11:33:06 +0530 |
---|---|---|
committer | Atin Mukherjee <amukherj@redhat.com> | 2018-05-03 17:57:33 +0000 |
commit | c63b278947dbc134e08331a097cf2041cf98c545 (patch) | |
tree | a21b05bdc4ed7c27abfeaa61b25d949e0acf07bd /cli/src | |
parent | f46047ea0f36084f4456887673552a01b926382d (diff) |
cli/glusterd: Add warning message in cli for user to check
force-migration config for remove-brick operation.
The cli will take input from the user before starting "remove-brick"
start operation. The message/confirmation looks like the following:
<Running remove-brick with cluster.force-migration enabled can result
in data corruption. It is safer to disable this option so that files
that receive writes during migration are not migrated. Files that are
not migrated can then be manually copied after the remove-brick commit
operation. Do you want to continue with your current
cluster.force-migration settings? (y/n)>
And also question for COMMIT_FORCE is changed.
Fixes: bz#1572586
Change-Id: Ifdb6b108a646f50339dd196d6e65962864635139
Signed-off-by: Susant Palai <spalai@redhat.com>
Diffstat (limited to 'cli/src')
-rw-r--r-- | cli/src/cli-cmd-parser.c | 8 | ||||
-rw-r--r-- | cli/src/cli-cmd-volume.c | 24 | ||||
-rw-r--r-- | cli/src/cli.h | 2 |
3 files changed, 26 insertions, 8 deletions
diff --git a/cli/src/cli-cmd-parser.c b/cli/src/cli-cmd-parser.c index 950067550be..29043e09810 100644 --- a/cli/src/cli-cmd-parser.c +++ b/cli/src/cli-cmd-parser.c @@ -1991,7 +1991,7 @@ out: int32_t cli_cmd_volume_remove_brick_parse (const char **words, int wordcount, dict_t **options, int *question, - int *brick_count) + int *brick_count, int32_t *comm) { dict_t *dict = NULL; char *volname = NULL; @@ -2060,10 +2060,10 @@ cli_cmd_volume_remove_brick_parse (const char **words, int wordcount, wordcount--; if (!strcmp ("start", w)) { command = GF_OP_CMD_START; - } else if (!strcmp ("commit", w)) { - command = GF_OP_CMD_COMMIT; if (question) *question = 1; + } else if (!strcmp ("commit", w)) { + command = GF_OP_CMD_COMMIT; } else if (!strcmp ("stop", w)) { command = GF_OP_CMD_STOP; } else if (!strcmp ("status", w)) { @@ -2156,6 +2156,8 @@ out: GF_FREE (tmp_brick); GF_FREE (tmp_brick1); + *comm = command; + return ret; } diff --git a/cli/src/cli-cmd-volume.c b/cli/src/cli-cmd-volume.c index 6dade9256e4..ee7e8f94c9e 100644 --- a/cli/src/cli-cmd-volume.c +++ b/cli/src/cli-cmd-volume.c @@ -2023,20 +2023,37 @@ cli_cmd_volume_remove_brick_cbk (struct cli_state *state, char *event_str = NULL; int event_ret = -1; #endif - const char *question = "Removing brick(s) can result in data loss. " - "Do you want to Continue?"; + int32_t command = GF_OP_CMD_NONE; + char *question = NULL; frame = create_frame (THIS, THIS->ctx->pool); if (!frame) goto out; ret = cli_cmd_volume_remove_brick_parse (words, wordcount, &options, - &need_question, &brick_count); + &need_question, &brick_count, + &command); if (ret) { cli_usage_out (word->pattern); parse_error = 1; goto out; } + + if (command == GF_OP_CMD_COMMIT_FORCE) { + question = "Remove-brick force will not migrate files from the " + "removed bricks, so they will no longer be available" + " on the volume.\nDo you want to continue?"; + } else if (command == GF_OP_CMD_START) { + question = "Running remove-brick with cluster.force-migration" + " enabled can result in data corruption. It is safer" + " to disable this option so that files that receive " + "writes during migration are not migrated.\nFiles " + "that are not migrated can then be manually copied " + "after the remove-brick commit operation.\nDo you " + "want to continue with your current " + "cluster.force-migration settings?"; + } + if (!brick_count) { cli_err ("No bricks specified"); cli_usage_out (word->pattern); @@ -2065,7 +2082,6 @@ cli_cmd_volume_remove_brick_cbk (struct cli_state *state, } if (!(state->mode & GLUSTER_MODE_SCRIPT) && need_question) { - /* we need to ask question only in case of 'commit or force' */ answer = cli_cmd_get_confirmation (state, question); if (GF_ANSWER_NO == answer) { ret = 0; diff --git a/cli/src/cli.h b/cli/src/cli.h index 68dcb8c531f..3421d6911fb 100644 --- a/cli/src/cli.h +++ b/cli/src/cli.h @@ -279,7 +279,7 @@ cli_cmd_volume_old_tier_parse (const char **words, int wordcount, int32_t cli_cmd_volume_remove_brick_parse (const char **words, int wordcount, dict_t **options, int *question, - int *brick_count); + int *brick_count, int32_t *command); int32_t cli_cmd_volume_replace_brick_parse (const char **words, int wordcount, |