]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
mon/OSDMonitor: make error output more human-readable
authorxie xingguo <xie.xingguo@zte.com.cn>
Thu, 27 Jul 2017 11:53:49 +0000 (19:53 +0800)
committerxie xingguo <xie.xingguo@zte.com.cn>
Sat, 29 Jul 2017 08:58:50 +0000 (16:58 +0800)
Was:

./bin/ceph osd crush weight-set reweight rbd osd.0  1 2 3 4 5
Error ENOENT: weight_set_size != 5 for bucket -1weight_set_size != 5 for bucket -2weight_set_size != 5 for bucket -3weight_set_size != 5 for bucket -4item 0 not found in crush map

Now:
./bin/ceph osd crush weight-set reweight rbd osd.0  1 2 3 4 5
Error EINVAL: must specify exact 3 weight values

Signed-off-by: xie xingguo <xie.xingguo@zte.com.cn>
src/mon/OSDMonitor.cc

index b0c1f107c6956d1acfa63d39176c6c49af101c61..6ab67676f5e7607ca905edc035deebe39dcdad9b 100644 (file)
@@ -7624,6 +7624,13 @@ bool OSDMonitor::prepare_command_impl(MonOpRequestRef op,
        err = -ENOENT;
        goto reply;
       }
+      auto arg_map = newcrush.choose_args_get(pool);
+      int positions = newcrush.get_choose_args_positions(arg_map);
+      if (weight.size() != (size_t)positions) {
+         ss << "must specify exact " << positions << " weight values";
+         err = -EINVAL;
+         goto reply;
+      }
     } else {
       pool = CrushWrapper::DEFAULT_CHOOSE_ARGS;
       if (!newcrush.have_choose_args(pool)) {