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