From 8c761c47978fc21f13c27596a8674a7879f0f8a5 Mon Sep 17 00:00:00 2001 From: Sage Weil Date: Mon, 31 Mar 2014 10:01:43 -0700 Subject: [PATCH] mon: make 'ceph osd erasure-code-profile set ...' idempotent Signed-off-by: Sage Weil --- qa/workunits/cephtool/test.sh | 7 +++++++ src/mon/OSDMonitor.cc | 14 ++++++++++---- 2 files changed, 17 insertions(+), 4 deletions(-) diff --git a/qa/workunits/cephtool/test.sh b/qa/workunits/cephtool/test.sh index f572a8da310f2..df5d941b68103 100755 --- a/qa/workunits/cephtool/test.sh +++ b/qa/workunits/cephtool/test.sh @@ -476,6 +476,13 @@ ceph osd pool set rbd cache_min_evict_age 234 ceph osd pool get rbd crush_ruleset | grep 'crush_ruleset: 0' +ceph osd erasure-code-profile set fooprofile a=b c=d +ceph osd erasure-code-profile set fooprofile a=b c=d +expect_false ceph osd erasure-code-profile set fooprofile a=b c=d e=f +ceph osd erasure-code-profile set fooprofile a=b c=d e=f --force +ceph osd erasure-code-profile set fooprofile a=b c=d e=f +expect_false ceph osd erasure-code-profile set fooprofile a=b c=d e=f g=h + set +e diff --git a/src/mon/OSDMonitor.cc b/src/mon/OSDMonitor.cc index b721ddd83c2f9..28c35692bdc85 100644 --- a/src/mon/OSDMonitor.cc +++ b/src/mon/OSDMonitor.cc @@ -4033,10 +4033,16 @@ bool OSDMonitor::prepare_command_impl(MMonCommand *m, if (err) goto reply; - if (osdmap.has_erasure_code_profile(name) && !force) { - err = -EPERM; - ss << "will not override erasure code profile " << name; - goto reply; + if (osdmap.has_erasure_code_profile(name)) { + if (osdmap.get_erasure_code_profile(name) == profile_map) { + err = 0; + goto reply; + } + if (!force) { + err = -EPERM; + ss << "will not override erasure code profile " << name; + goto reply; + } } if (pending_inc.has_erasure_code_profile(name)) { -- 2.39.5