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