mirror of
https://github.com/ceph/ceph
synced 2025-02-19 08:57:27 +00:00
mon/OSDMonitor: make 'osd crush rule rename' idempotent
Fixes: http://tracker.ceph.com/issues/21162 Signed-off-by: xie xingguo <xie.xingguo@zte.com.cn>
This commit is contained in:
parent
3e0506a9a5
commit
cd2191c3f1
@ -38,12 +38,14 @@ ceph osd pool rm ec-foo ec-foo --yes-i-really-really-mean-it
|
||||
ceph osd crush rule ls | grep foo
|
||||
|
||||
ceph osd crush rule rename foo foo-asdf
|
||||
ceph osd crush rule rename foo foo-asdf # idempotent
|
||||
ceph osd crush rule rename bar bar-asdf
|
||||
ceph osd crush rule ls | grep 'foo-asdf'
|
||||
ceph osd crush rule ls | grep 'bar-asdf'
|
||||
ceph osd crush rule rm foo 2>&1 | grep 'does not exist'
|
||||
ceph osd crush rule rm bar 2>&1 | grep 'does not exist'
|
||||
ceph osd crush rule rename foo-asdf foo
|
||||
ceph osd crush rule rename foo-asdf foo # idempotent
|
||||
ceph osd crush rule rename bar-asdf bar
|
||||
ceph osd crush rule ls | expect_false grep 'foo-asdf'
|
||||
ceph osd crush rule ls | expect_false grep 'bar-asdf'
|
||||
|
@ -8627,6 +8627,15 @@ bool OSDMonitor::prepare_command_impl(MonOpRequestRef op,
|
||||
|
||||
CrushWrapper newcrush;
|
||||
_get_pending_crush(newcrush);
|
||||
if (!newcrush.rule_exists(srcname) && newcrush.rule_exists(dstname)) {
|
||||
// srcname does not exist and dstname already exists
|
||||
// suppose this is a replay and return success
|
||||
// (so this command is idempotent)
|
||||
ss << "already renamed to '" << dstname << "'";
|
||||
err = 0;
|
||||
goto reply;
|
||||
}
|
||||
|
||||
err = newcrush.rename_rule(srcname, dstname, &ss);
|
||||
if (err < 0) {
|
||||
// ss has reason for failure
|
||||
|
Loading…
Reference in New Issue
Block a user