]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
mon: add 'osd destroy-new' command that only destroys NEW osd slots 22429/head
authorSage Weil <sage@redhat.com>
Tue, 5 Jun 2018 22:30:14 +0000 (17:30 -0500)
committerSage Weil <sage@redhat.com>
Tue, 5 Jun 2018 22:36:06 +0000 (17:36 -0500)
ceph-volume may run into a problem and want to clean up, but we do not
want to give it blanket access to the 'osd destroy' command.  Instead,
make an 'osd destroy-new' that can only create new OSDs (ones that are
in the process of being created but have never booted yet).

Signed-off-by: Sage Weil <sage@redhat.com>
qa/workunits/cephtool/test.sh
src/mon/MonCommands.h
src/mon/OSDMonitor.cc

index cb40c715146b30ad8906cb9d9546b24c6f70d7f3..e525df9452cb775b4ded088769752cfe9e19b8ec 100755 (executable)
@@ -1334,7 +1334,7 @@ function test_mon_osd_create_destroy()
   expect_false ceph auth get-key client.osd-lockbox.$uuid2
   expect_false ceph config-key exists dm-crypt/osd/$uuid2/luks
 
-  ceph osd destroy osd.$id2 --yes-i-really-mean-it
+  ceph osd destroy-new osd.$id2 --yes-i-really-mean-it
   ceph osd destroy $id2 --yes-i-really-mean-it
   ceph osd find $id2
   expect_false ceph auth get-key osd.$id2
index 30263d913e4fcec7acef0fb2d1fcc03bcb619573..9739485bd715fe6503960f35f972f34dd5d5615f 100644 (file)
@@ -874,6 +874,13 @@ COMMAND("osd destroy " \
         "but removes cephx keys, config-key data and lockbox keys, "\
         "rendering data permanently unreadable.", \
         "osd", "rw", "cli,rest")
+COMMAND("osd destroy-new " \
+        "name=id,type=CephOsdName " \
+        "name=sure,type=CephChoices,strings=--yes-i-really-mean-it,req=false", \
+        "mark osd as being destroyed. Keeps the ID intact (allowing reuse), " \
+        "but removes cephx keys, config-key data and lockbox keys, "\
+        "rendering data permanently unreadable.  Only works on new, unbooted osd ids.", \
+        "osd", "rw", "cli,rest")
 COMMAND("osd purge " \
         "name=id,type=CephOsdName " \
         "name=sure,type=CephChoices,strings=--yes-i-really-mean-it,req=false", \
index f0400c2a0d1c63d7e7fc8ffdefeee6cb4326bd49..081cbcfe2f5e5da6050fa448b556565c492adf97 100644 (file)
@@ -10496,7 +10496,9 @@ bool OSDMonitor::prepare_command_impl(MonOpRequestRef op,
       return true;
     }
 
-  } else if (prefix == "osd destroy" || prefix == "osd purge") {
+  } else if (prefix == "osd destroy" ||
+            prefix == "osd purge" ||
+            prefix == "osd destroy-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),
      * and that we are okay with scrubbing all its cephx keys and config-key
@@ -10525,7 +10527,8 @@ bool OSDMonitor::prepare_command_impl(MonOpRequestRef op,
       goto reply;
     }
 
-    bool is_destroy = (prefix == "osd destroy");
+    bool is_destroy = (prefix == "osd destroy" ||
+                      prefix == "osd destroy-new");
     if (!is_destroy) {
       assert("osd purge" == prefix);
     }
@@ -10552,6 +10555,13 @@ bool OSDMonitor::prepare_command_impl(MonOpRequestRef op,
       goto reply;
     }
 
+    if (prefix == "osd destroy-new" &&
+       (osdmap.get_state(id) & CEPH_OSD_NEW) == 0) {
+      ss << "osd." << id << " is not new";
+      err = -EPERM;
+      goto reply;
+    }
+
     bool goto_reply = false;
 
     paxos->plug();