14f8ab
From 12ed9226fa24d073ab2b89692194b454a194c379 Mon Sep 17 00:00:00 2001
14f8ab
From: Sanju Rakonde <srakonde@redhat.com>
14f8ab
Date: Thu, 4 Jun 2020 15:14:29 +0530
14f8ab
Subject: [PATCH 400/449] cli: throw a warning if replica count greater than 3
14f8ab
14f8ab
As volumes with replica count greater than 3 are not
14f8ab
supported, a warning message is be thrown to user
14f8ab
while creating the volume with replica count greater
14f8ab
than 3 or while converting a volume to replica > 3
14f8ab
volume by add-brick/remove-brick operations.
14f8ab
14f8ab
Label: DOWNSTREAM ONLY
14f8ab
14f8ab
BUG: 1763129
14f8ab
Change-Id: I5a32a5a2d99b5175fb692dfcab27396089f24b72
14f8ab
Signed-off-by: Sanju Rakonde <srakonde@redhat.com>
14f8ab
Reviewed-on: https://code.engineering.redhat.com/gerrit/202338
14f8ab
Tested-by: RHGS Build Bot <nigelb@redhat.com>
14f8ab
Reviewed-by: Mohit Agrawal <moagrawa@redhat.com>
14f8ab
Reviewed-by: Ravishankar Narayanankutty <ravishankar@redhat.com>
14f8ab
Reviewed-by: Sunil Kumar Heggodu Gopala Acharya <sheggodu@redhat.com>
14f8ab
---
14f8ab
 cli/src/cli-cmd-parser.c | 45 +++++++++++++++++++++++++++++++++++++++++++++
14f8ab
 1 file changed, 45 insertions(+)
14f8ab
14f8ab
diff --git a/cli/src/cli-cmd-parser.c b/cli/src/cli-cmd-parser.c
14f8ab
index ac0a263..5e7ce53 100644
14f8ab
--- a/cli/src/cli-cmd-parser.c
14f8ab
+++ b/cli/src/cli-cmd-parser.c
14f8ab
@@ -619,6 +619,23 @@ cli_cmd_volume_create_parse(struct cli_state *state, const char **words,
14f8ab
                     }
14f8ab
                 }
14f8ab
             }
14f8ab
+
14f8ab
+            if (replica_count > 3) {
14f8ab
+                if (strcmp(words[wordcount - 1], "force")) {
14f8ab
+                    question =
14f8ab
+                        "Volumes with replica count greater than 3 are"
14f8ab
+                        "not supported. \nDo you still want to continue?\n";
14f8ab
+                    answer = cli_cmd_get_confirmation(state, question);
14f8ab
+                    if (GF_ANSWER_NO == answer) {
14f8ab
+                        gf_log("cli", GF_LOG_ERROR,
14f8ab
+                               "Volume create "
14f8ab
+                               "cancelled, exiting");
14f8ab
+                        ret = -1;
14f8ab
+                        goto out;
14f8ab
+                    }
14f8ab
+                }
14f8ab
+            }
14f8ab
+
14f8ab
             ret = dict_set_int32(dict, "replica-count", replica_count);
14f8ab
             if (ret)
14f8ab
                 goto out;
14f8ab
@@ -1815,6 +1832,20 @@ cli_cmd_volume_add_brick_parse(struct cli_state *state, const char **words,
14f8ab
                     goto out;
14f8ab
                 }
14f8ab
             }
14f8ab
+        } else if (count > 3) {
14f8ab
+            if (strcmp(words[wordcount - 1], "force")) {
14f8ab
+                question =
14f8ab
+                    "Volumes with replica count greater than 3 are"
14f8ab
+                    "not supported. \nDo you still want to continue?\n";
14f8ab
+                answer = cli_cmd_get_confirmation(state, question);
14f8ab
+                if (GF_ANSWER_NO == answer) {
14f8ab
+                    gf_log("cli", GF_LOG_ERROR,
14f8ab
+                           "add-brick "
14f8ab
+                           "cancelled, exiting");
14f8ab
+                    ret = -1;
14f8ab
+                    goto out;
14f8ab
+                }
14f8ab
+            }
14f8ab
         }
14f8ab
     } else if ((strcmp(w, "stripe")) == 0) {
14f8ab
         cli_err("stripe option not supported");
14f8ab
@@ -2082,6 +2113,20 @@ cli_cmd_volume_remove_brick_parse(struct cli_state *state, const char **words,
14f8ab
                     goto out;
14f8ab
                 }
14f8ab
             }
14f8ab
+        } else if (count > 3) {
14f8ab
+            if (strcmp(words[wordcount - 1], "force")) {
14f8ab
+                ques =
14f8ab
+                    "Volumes with replica count greater than 3 are"
14f8ab
+                    "not supported. \nDo you still want to continue?\n";
14f8ab
+                answer = cli_cmd_get_confirmation(state, ques);
14f8ab
+                if (GF_ANSWER_NO == answer) {
14f8ab
+                    gf_log("cli", GF_LOG_ERROR,
14f8ab
+                           "Remove-brick "
14f8ab
+                           "cancelled, exiting");
14f8ab
+                    ret = -1;
14f8ab
+                    goto out;
14f8ab
+                }
14f8ab
+            }
14f8ab
         }
14f8ab
 
14f8ab
         ret = dict_set_int32(dict, "replica-count", count);
14f8ab
-- 
14f8ab
1.8.3.1
14f8ab