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