Skip to content

Commit

Permalink
Merge pull request #20839 from guzhongyan/tree-from-cleanup
Browse files Browse the repository at this point in the history
mon/OSDMonitor: clean up cmd 'osd tree-from'

Reviewed-by: Kefu Chai <kchai@redhat.com>
  • Loading branch information
xiexingguo committed Mar 13, 2018
2 parents 41ec438 + 241af6c commit 224c3cb
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 2 deletions.
3 changes: 3 additions & 0 deletions qa/workunits/mon/crush_ops.sh
Expand Up @@ -90,6 +90,9 @@ ceph osd tree | grep -c host1 | grep -q 1 # now an orphan
ceph osd crush rm osd.$o1 host1
ceph osd crush rm host1
ceph osd tree | grep -c host1 | grep -q 0
expect_false ceph osd tree-from host1
ceph osd tree-from host2
expect_false ceph osd tree-from osd.$o2

expect_false ceph osd crush rm bar # not empty
ceph osd crush unlink host2
Expand Down
16 changes: 14 additions & 2 deletions src/mon/OSDMonitor.cc
Expand Up @@ -3709,8 +3709,20 @@ bool OSDMonitor::preprocess_command(MonOpRequestRef op)
rdata.append(ds);
} else if (prefix == "osd tree" || prefix == "osd tree-from") {
string bucket;
if (prefix == "osd tree-from")
cmd_getval(cct, cmdmap, "bucket", bucket);
if (prefix == "osd tree-from") {
cmd_getval(cct, cmdmap, "bucket", bucket);
if (!osdmap.crush->name_exists(bucket)) {
ss << "bucket '" << bucket << "' does not exist";
r = -ENOENT;
goto reply;
}
int id = osdmap.crush->get_item_id(bucket);
if (id >= 0) {
ss << "\"" << bucket << "\" is not a bucket";
r = -EINVAL;
goto reply;
}
}

vector<string> states;
cmd_getval(cct, cmdmap, "states", states);
Expand Down

0 comments on commit 224c3cb

Please sign in to comment.