From: Sage Weil Date: Mon, 7 Nov 2016 16:25:05 +0000 (-0500) Subject: mon/OSDMonitor: remember old weight on 'osd out' X-Git-Tag: v11.1.0~334^2~3 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=73a2c11e94fb4dfc45d72690445b0b20682ef680;p=ceph.git mon/OSDMonitor: remember old weight on 'osd out' If we have an OSD with a weight that's not 1.0 and mark it out, we should restore the same weight when we mark it back in. We already do this when an OSD is automatically marked out, just not when it is explicitly marked out. Signed-off-by: Sage Weil --- diff --git a/PendingReleaseNotes b/PendingReleaseNotes index 0bbc2aa25f4b..1591c49b07c3 100644 --- a/PendingReleaseNotes +++ b/PendingReleaseNotes @@ -43,6 +43,10 @@ If you had manually configured the mon to use rocksdb, this file should be created and filled with the string "rocksdb" (newline optional). +* The 'osd out ...' and 'osd in ...' commands now preserve the OSD + weight. Previously the mons would only preserve the weight if the + mon automatically marked and OSD out and then in, but not when an + admin did so explicitly. 11.0.0 ------ diff --git a/qa/workunits/cephtool/test.sh b/qa/workunits/cephtool/test.sh index 7faa0dcc6b4c..164a0e7c3eec 100755 --- a/qa/workunits/cephtool/test.sh +++ b/qa/workunits/cephtool/test.sh @@ -1145,6 +1145,13 @@ function test_mon_osd() ceph osd dump | grep 'osd.0.*in' ceph osd find 0 + # make sure mark out preserves weight + ceph osd reweight osd.0 .5 + ceph osd dump | grep ^osd.0 | grep 'weight 0.5' + ceph osd out 0 + ceph osd in 0 + ceph osd dump | grep ^osd.0 | grep 'weight 0.5' + f=$TEMP_DIR/map.$$ ceph osd getcrushmap -o $f [ -s $f ] diff --git a/src/mon/OSDMonitor.cc b/src/mon/OSDMonitor.cc index 24e0d5f2fc19..9ba604cc1b22 100644 --- a/src/mon/OSDMonitor.cc +++ b/src/mon/OSDMonitor.cc @@ -6630,6 +6630,12 @@ bool OSDMonitor::prepare_command_impl(MonOpRequestRef op, ss << "osd." << osd << " is already out. "; } else { pending_inc.new_weight[osd] = CEPH_OSD_OUT; + if (osdmap.osd_weight[osd]) { + if (pending_inc.new_xinfo.count(osd) == 0) { + pending_inc.new_xinfo[osd] = osdmap.osd_xinfo[osd]; + } + pending_inc.new_xinfo[osd].old_weight = osdmap.osd_weight[osd]; + } ss << "marked out osd." << osd << ". "; any = true; } @@ -6637,7 +6643,15 @@ bool OSDMonitor::prepare_command_impl(MonOpRequestRef op, if (osdmap.is_in(osd)) { ss << "osd." << osd << " is already in. "; } else { - pending_inc.new_weight[osd] = CEPH_OSD_IN; + if (osdmap.osd_xinfo[osd].old_weight > 0) { + pending_inc.new_weight[osd] = osdmap.osd_xinfo[osd].old_weight; + if (pending_inc.new_xinfo.count(osd) == 0) { + pending_inc.new_xinfo[osd] = osdmap.osd_xinfo[osd]; + } + pending_inc.new_xinfo[osd].old_weight = 0; + } else { + pending_inc.new_weight[osd] = CEPH_OSD_IN; + } ss << "marked in osd." << osd << ". "; any = true; }