]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
mon/OSDMonitor: remember old weight on 'osd out'
authorSage Weil <sage@redhat.com>
Mon, 7 Nov 2016 16:25:05 +0000 (11:25 -0500)
committerSage Weil <sage@redhat.com>
Mon, 7 Nov 2016 16:28:43 +0000 (11:28 -0500)
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 <sage@redhat.com>
PendingReleaseNotes
qa/workunits/cephtool/test.sh
src/mon/OSDMonitor.cc

index 0bbc2aa25f4b3c08fe292d16dd84f6f550597d9b..1591c49b07c34530ac3e40d5453602f5d6e421df 100644 (file)
   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
 ------
index 7faa0dcc6b4c3b57a65a1863bf9297e5edfb5394..164a0e7c3eec34984628ace10854ce18ec31afb6 100755 (executable)
@@ -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 ]
index 24e0d5f2fc19fcdd22f65d17add54a27d83e457a..9ba604cc1b2261ab5b7b4e1af5cfee2e5e98dd60 100644 (file)
@@ -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;
        }