The output json string is invalid for 'osd crush tree --format=json'
command. It contains a array of 'nodes' and a array of 'stray', but
not in a json object, and the stray array was not implemented.
Applications which depends on the output of the above MonCommand will
occur json parse error.
Signed-off-by: Oshyn Song <dualyangsong@gmail.com>
f->open_array_section("nodes");
Parent::dump(f);
f->close_section();
+
+ // There is no stray bucket whose id is a negative number, so just get
+ // the max_id and iterate from 0 to max_id to dump stray osds.
f->open_array_section("stray");
+ int32_t max_id = -1;
+ if (!crush->name_map.empty()) {
+ max_id = crush->name_map.rbegin()->first;
+ }
+ for (int32_t i = 0; i <= max_id; i++) {
+ if (crush->item_exists(i) && !is_touched(i) && should_dump(i)) {
+ dump_item(CrushTreeDumper::Item(i, 0, 0, 0), f);
+ }
+ }
f->close_section();
}
};
bool show_shadow = shadow == "--show-shadow";
boost::scoped_ptr<Formatter> f(Formatter::create(format));
if (f) {
+ f->open_object_section("crush_tree");
osdmap.crush->dump_tree(nullptr,
f.get(),
osdmap.get_pool_names(),
show_shadow);
+ f->close_section();
f->flush(rdata);
} else {
ostringstream ss;