From 7974a0fd9527c3597b5da4fe67878bd47273fe36 Mon Sep 17 00:00:00 2001 From: xie xingguo Date: Thu, 27 Jul 2017 19:53:49 +0800 Subject: [PATCH] mon/OSDMonitor: make error output more human-readable 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 --- src/mon/OSDMonitor.cc | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/mon/OSDMonitor.cc b/src/mon/OSDMonitor.cc index b0c1f107c6956..6ab67676f5e76 100644 --- a/src/mon/OSDMonitor.cc +++ b/src/mon/OSDMonitor.cc @@ -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)) { -- 2.39.5