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