]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
mon: validate new crush for unknown names
authorKefu Chai <kchai@redhat.com>
Mon, 25 May 2015 12:14:32 +0000 (20:14 +0800)
committerKefu Chai <kchai@redhat.com>
Sun, 31 May 2015 17:24:54 +0000 (01:24 +0800)
* the "osd tree dump" command enumerates all buckets/osds found in either the
  crush map or the osd map. but the newly set crushmap is not validated for
  the dangling references, so we need to check to see if any item in new crush
  map is referencing unknown type/name when a new crush map is sent to
  monitor, reject it if any.

Fixes: #11680
Signed-off-by: Kefu Chai <kchai@redhat.com>
src/mon/OSDMonitor.cc
src/test/mon/osd-crush.sh

index 0fb63cfb6893a21b01bf805dbc556e52dbe0d311..91e249ce679d94f3e6e7ba878e24293987dd618d 100644 (file)
@@ -4841,6 +4841,11 @@ bool OSDMonitor::prepare_command_impl(MMonCommand *m,
     dout(10) << " testing map" << dendl;
     stringstream ess;
     CrushTester tester(crush, ess);
+    if (!tester.check_name_maps()) {
+      err = -EINVAL;
+      ss << ess.str();
+      goto reply;
+    }
     // XXX: Use mon_lease as a timeout value for crushtool.
     // If the crushtool consistently takes longer than 'mon_lease' seconds,
     // then we would consistently trigger an election before the command
index 4857ca2b2595690ce8de68a73289f72f8f9b0e94..8abfd873046334f777a72cd455b7449301564a23 100755 (executable)
@@ -205,6 +205,19 @@ function TEST_crush_rename_bucket() {
     ./ceph osd crush rename-bucket nonexistent something 2>&1 | grep "Error ENOENT" || return 1
 }
 
+function TEST_crush_reject_empty() {
+    local dir=$1
+    run_mon $dir a || return 1
+    # should have at least one OSD
+    run_osd $dir 0 || return 1
+
+    local empty_map=$dir/empty_map
+    :> $empty_map.txt
+    ./crushtool -c $empty_map.txt -o $empty_map.map || return 1
+    expect_failure $dir "Error EINVAL" \
+        ./ceph osd setcrushmap -i $empty_map.map || return 1
+}
+
 main osd-crush "$@"
 
 # Local Variables: