From: Sage Weil Date: Tue, 26 Jun 2018 12:34:46 +0000 (-0500) Subject: mon,mgr: guard 'osd purge' with safe-to-destroy check X-Git-Tag: v14.0.1~684^2~1 X-Git-Url: http://git.apps.os.sepia.ceph.com/?a=commitdiff_plain;h=26fe2ab6f0881b4793839f9b408d5373c200c398;p=ceph.git mon,mgr: guard 'osd purge' with safe-to-destroy check Do the same thing that we do with 'osd destroy'. Signed-off-by: Sage Weil --- diff --git a/src/mgr/DaemonServer.cc b/src/mgr/DaemonServer.cc index ae427392e6df7..41c7dad8b7415 100644 --- a/src/mgr/DaemonServer.cc +++ b/src/mgr/DaemonServer.cc @@ -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 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\"" "}"; diff --git a/src/mgr/MgrCommands.h b/src/mgr/MgrCommands.h index 6d532237ed0bb..6d30db36506fd 100644 --- a/src/mgr/MgrCommands.h +++ b/src/mgr/MgrCommands.h @@ -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", diff --git a/src/mon/MonCommands.h b/src/mon/MonCommands.h index ccd533f5f2386..7f9847d74d32f 100644 --- a/src/mon/MonCommands.h +++ b/src/mon/MonCommands.h @@ -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", \ diff --git a/src/mon/OSDMonitor.cc b/src/mon/OSDMonitor.cc index ff5dd5fbb9e0f..02900318feedc 100644 --- a/src/mon/OSDMonitor.cc +++ b/src/mon/OSDMonitor.cc @@ -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); }