]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
mon,mgr: guard 'osd purge' with safe-to-destroy check
authorSage Weil <sage@redhat.com>
Tue, 26 Jun 2018 12:34:46 +0000 (07:34 -0500)
committerSage Weil <sage@redhat.com>
Wed, 1 Aug 2018 13:12:15 +0000 (08:12 -0500)
Do the same thing that we do with 'osd destroy'.

Signed-off-by: Sage Weil <sage@redhat.com>
src/mgr/DaemonServer.cc
src/mgr/MgrCommands.h
src/mon/MonCommands.h
src/mon/OSDMonitor.cc

index ae427392e6df7d35119178fd55f84e5511ed5ce2..41c7dad8b741587af44bc63df1999fa0e384dffa 100644 (file)
@@ -1202,7 +1202,8 @@ bool DaemonServer::handle_command(MCommand *m)
       return true;
     }
   } else if (prefix == "osd safe-to-destroy" ||
-            prefix == "osd destroy") {
+            prefix == "osd destroy" ||
+            prefix == "osd purge") {
     set<int> osds;
     int r = 0;
     if (prefix == "osd safe-to-destroy") {
@@ -1284,11 +1285,12 @@ bool DaemonServer::handle_command(MCommand *m)
       r = -EBUSY;
     }
 
-    if (r && prefix == "osd destroy") {
+    if (r && (prefix == "osd destroy" ||
+             prefix == "osd purge")) {
       string sure;
       if (!cmd_getval(cct, cmdctx->cmdmap, "sure", sure) ||
          sure != "--force") {
-       ss << "\nYou can proceed with OSD removal by passing --force, but be warned that this will likely mean real, permanent data loss.";
+       ss << "\nYou can proceed by passing --force, but be warned that this will likely mean real, permanent data loss.";
       } else {
        r = 0;
       }
@@ -1297,10 +1299,11 @@ bool DaemonServer::handle_command(MCommand *m)
       cmdctx->reply(r, ss);
       return true;
     }
-    if (prefix == "osd destroy") {
+    if (prefix == "osd destroy" ||
+       prefix == "osd purge") {
       const string cmd =
        "{"
-       "\"prefix\": \"osd destroy-actual\", "
+       "\"prefix\": \"" + prefix + "-actual\", "
        "\"id\": " + stringify(osds) + ", "
        "\"sure\": \"--yes-i-really-mean-it\""
        "}";
index 6d532237ed0bb81701a2a2f009795cfabd010a43..6d30db36506fd8ce9871f04c382766f277dbf4a6 100644 (file)
@@ -114,6 +114,12 @@ COMMAND("osd destroy "         \
         "but removes cephx keys, config-key data and lockbox keys, "\
         "rendering data permanently unreadable.", \
         "osd", "rw", "cli,rest")
+COMMAND("osd purge " \
+        "name=id,type=CephOsdName " \
+        "name=sure,type=CephString,req=false",                      \
+        "purge all osd data from the monitors including the OSD id " \
+       "and CRUSH position",                                        \
+       "osd", "rw", "cli,rest")
 
 COMMAND("osd safe-to-destroy name=ids,type=CephString,n=N",
        "check whether osd(s) can be safely destroyed without reducing data durability",
index ccd533f5f238699290b01198039ed2828e4b8330..7f9847d74d32f37aef8b13785c5fbd88b3a53d92 100644 (file)
@@ -884,12 +884,12 @@ COMMAND("osd purge-new " \
         "purge all traces of an OSD that was partially created but never " \
        "started", \
         "osd", "rw", "cli,rest")
-COMMAND("osd purge " \
+COMMAND_WITH_FLAG("osd purge-actual " \
         "name=id,type=CephOsdName " \
         "name=sure,type=CephChoices,strings=--yes-i-really-mean-it,req=false", \
         "purge all osd data from the monitors. Combines `osd destroy`, " \
         "`osd rm`, and `osd crush rm`.", \
-        "osd", "rw", "cli,rest")
+                 "osd", "rw", "cli,rest", FLAG(HIDDEN))
 COMMAND("osd lost " \
        "name=id,type=CephOsdName " \
        "name=sure,type=CephChoices,strings=--yes-i-really-mean-it,req=false", \
index ff5dd5fbb9e0f333b510526f3393c947d71b1c1e..02900318feedc2432996ebae9d56116377416eca 100644 (file)
@@ -10641,7 +10641,7 @@ bool OSDMonitor::prepare_command_impl(MonOpRequestRef op,
     }
 
   } else if (prefix == "osd destroy-actual" ||
-            prefix == "osd purge" ||
+            prefix == "osd purge-actual" ||
             prefix == "osd purge-new") {
     /* Destroying an OSD means that we don't expect to further make use of
      * the OSDs data (which may even become unreadable after this operation),
@@ -10678,7 +10678,7 @@ bool OSDMonitor::prepare_command_impl(MonOpRequestRef op,
 
     bool is_destroy = (prefix == "osd destroy-actual");
     if (!is_destroy) {
-      assert("osd purge" == prefix ||
+      assert("osd purge-actual" == prefix ||
             "osd purge-new" == prefix);
     }