]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
mon/OSDMonitor: max_osds must be > 0 for reweight-by-*
authorSage Weil <sage@redhat.com>
Sat, 30 Apr 2016 02:01:56 +0000 (22:01 -0400)
committerSage Weil <sage@redhat.com>
Wed, 4 May 2016 13:05:36 +0000 (09:05 -0400)
Include a few test cases.

Signed-off-by: Sage Weil <sage@redhat.com>
(cherry picked from commit 84bd0dce18f6dd0c35d7e6cfee91ce8c5a0f4db7)

qa/workunits/cephtool/test.sh
src/mon/OSDMonitor.cc

index 965cecd5f6a117538c9cd96498cf96ebc242471b..ecb6687d9fd752b1502c949dfe5ca798fe063018 100755 (executable)
@@ -1620,7 +1620,12 @@ function test_mon_osd_misc()
 
   ceph osd reweight-by-utilization 110
   ceph osd reweight-by-utilization 110 .5
+  expect_false ceph osd reweight-by-utilization 110 0
+  expect_false ceph osd reweight-by-utilization 110 -0.1
   ceph osd test-reweight-by-utilization 110 .5 --no-increasing
+  ceph osd test-reweight-by-utilization 110 .5 4 --no-increasing
+  expect_false ceph osd test-reweight-by-utilization 110 .5 0 --no-increasing
+  expect_false ceph osd test-reweight-by-utilization 110 .5 -10 --no-increasing
   ceph osd reweight-by-pg 110
   ceph osd test-reweight-by-pg 110 .5
   ceph osd reweight-by-pg 110 rbd
index f9cf0fd80272e030d7a3513eb707e7267b54eadc..ca825bff39c2bf655c54429614ea21e25c2674da 100644 (file)
@@ -7598,6 +7598,11 @@ done:
     }
     int64_t max_osds = g_conf->mon_reweight_max_osds;
     cmd_getval(g_ceph_context, cmdmap, "max_osds", max_osds);
+    if (max_osds <= 0) {
+      ss << "max_osds " << max_osds << " must be positive";
+      err = -EINVAL;
+      goto reply;
+    }
     string no_increasing;
     cmd_getval(g_ceph_context, cmdmap, "no_increasing", no_increasing);
     string out_str;