From: Sage Weil Date: Thu, 13 Jun 2013 21:01:01 +0000 (-0700) Subject: mon: fix idempotency of 'osd crush add' X-Git-Tag: v0.65~81 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=9a7ed0b3f8df5bd74133f216bad61ae71eab0816;p=ceph.git mon: fix idempotency of 'osd crush add' If we add an item that already exists in particular position, we should update instead of inserting it; the CrushWrapper methods are not idempotent. Signed-off-by: Sage Weil --- diff --git a/qa/workunits/mon/crush_ops.sh b/qa/workunits/mon/crush_ops.sh index 748d00bc363..4f66e552153 100755 --- a/qa/workunits/mon/crush_ops.sh +++ b/qa/workunits/mon/crush_ops.sh @@ -27,10 +27,15 @@ ceph osd crush add-bucket foo root o1=`ceph osd create` o2=`ceph osd create` ceph osd crush add $o1 1 host=host1 root=foo +ceph osd crush add $o1 1 host=host1 root=foo # idemptoent ceph osd crush add $o2 1 host=host2 root=foo +ceph osd crush add $o2 1 host=host2 root=foo # idempotent ceph osd crush add-bucket bar root +ceph osd crush add-bucket bar root # idempotent ceph osd crush link host1 root=bar +ceph osd crush link host1 root=bar # idempotent ceph osd crush link host2 root=bar +ceph osd crush link host2 root=bar # idempotent ceph osd tree | grep -c osd.$o1 | grep -q 2 ceph osd tree | grep -c host1 | grep -q 2 diff --git a/src/mon/OSDMonitor.cc b/src/mon/OSDMonitor.cc index bdfea6f7a90..d785cf626c3 100644 --- a/src/mon/OSDMonitor.cc +++ b/src/mon/OSDMonitor.cc @@ -2579,7 +2579,8 @@ bool OSDMonitor::prepare_command(MMonCommand *m) _get_pending_crush(newcrush); string action; - if (prefix == "osd crush set") { + if (prefix == "osd crush set" || + newcrush.check_item_loc(g_ceph_context, id, loc, (int *)NULL)) { action = "set"; err = newcrush.update_item(g_ceph_context, id, weight, name, loc); } else {