]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
mon/OSDMonitor: make 'osd crush move ...' work on osds 13261/head
authorSage Weil <sage@redhat.com>
Wed, 18 Jan 2017 23:02:54 +0000 (17:02 -0600)
committerShinobu Kinjo <shinobu@redhat.com>
Tue, 21 Feb 2017 17:13:25 +0000 (02:13 +0900)
Currently it only allows you to move buckets, which is annoying and much
less useful.  To move an OSD you need to use create-or-move, which is
harder to use.

Fixes: http://tracker.ceph.com/issues/18587
Signed-off-by: Sage Weil <sage@redhat.com>
(cherry picked from commit 47956475dea8bb8e07331dd76344a60b776b5158)

Conflicts:
    qa/workunits/mon/crush_ops.sh: adapted "ceph osd find" to jewel syntax

qa/workunits/mon/crush_ops.sh
src/mon/OSDMonitor.cc

index adb3162038cb6f6183417aa4f4246d7091fafe34..5ea6601cd1907347e7b47594e7149984433683d9 100755 (executable)
@@ -74,11 +74,16 @@ ceph osd crush rm foo
 ceph osd crush rm osd.$o2 host2
 ceph osd crush rm host2
 
+ceph osd crush add-bucket foo host
+ceph osd crush move foo root=default rack=localrack
+
+ceph osd crush create-or-move osd.$o1 1.0 root=default
+ceph osd crush move osd.$o1 host=foo
+ceph osd find $o1 | grep host | grep foo
+
 ceph osd crush rm osd.$o1
 ceph osd crush rm osd.$o2
 
-ceph osd crush add-bucket foo host
-ceph osd crush move foo root=default rack=localrack
 ceph osd crush rm foo
 
 # test reweight
index b9cdc4d86023ceaed504f2a6d71f7654a483a962..9f5b0df858608d4717f4d7360108f6657e8fb84a 100644 (file)
@@ -5727,7 +5727,11 @@ bool OSDMonitor::prepare_command_impl(MonOpRequestRef op,
       int id = newcrush.get_item_id(name);
 
       if (!newcrush.check_item_loc(g_ceph_context, id, loc, (int *)NULL)) {
-       err = newcrush.move_bucket(g_ceph_context, id, loc);
+       if (id >= 0) {
+         err = newcrush.create_or_move_item(g_ceph_context, id, 0, name, loc);
+       } else {
+         err = newcrush.move_bucket(g_ceph_context, id, loc);
+       }
        if (err >= 0) {
          ss << "moved item id " << id << " name '" << name << "' to location " << loc << " in crush map";
          pending_inc.crush.clear();