diff options
author | Sage Weil <sage@inktank.com> | 2013-06-13 14:01:01 -0700 |
---|---|---|
committer | Sage Weil <sage@inktank.com> | 2013-06-13 14:42:05 -0700 |
commit | 9a7ed0b3f8df5bd74133f216bad61ae71eab0816 (patch) | |
tree | a9a5a392a61e30c3d62d17a93c1cb31edb33a94b | |
parent | 7e1cf87b5158c870e2a118ed6d316be8cb9818ce (diff) | |
download | ceph-9a7ed0b3f8df5bd74133f216bad61ae71eab0816.tar.gz |
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 <sage@inktank.com>
-rwxr-xr-x | qa/workunits/mon/crush_ops.sh | 5 | ||||
-rw-r--r-- | src/mon/OSDMonitor.cc | 3 |
2 files changed, 7 insertions, 1 deletions
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 { |