From: John Spray Date: Wed, 5 Mar 2014 15:50:53 +0000 (+0000) Subject: crush: revise JSON format for 'item' type X-Git-Tag: v0.78~88^2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=refs%2Fpull%2F1373%2Fhead;p=ceph.git crush: revise JSON format for 'item' type Commit a7e9a7b648 changed the JSON format of CRUSH rules such that the 'item' attribute on a step was sometimes an integer and sometimes a string. This commit separates the integer and string representations so that tools which rely on a 'item' consistently being an integer ID will work. Signed-off-by: John Spray --- diff --git a/src/crush/CrushWrapper.cc b/src/crush/CrushWrapper.cc index 8db506a6f2d00..61b8a8a564d77 100644 --- a/src/crush/CrushWrapper.cc +++ b/src/crush/CrushWrapper.cc @@ -1202,11 +1202,10 @@ void CrushWrapper::dump_rule(int ruleset, Formatter *f) const f->dump_string("op", "take"); { int item = get_rule_arg1(ruleset, j); + f->dump_int("item", item); + const char *name = get_item_name(item); - if (name == NULL) - f->dump_int("item", item); - else - f->dump_string("item", name); + f->dump_string("item_name", name ? name : ""); } break; case CRUSH_RULE_EMIT: diff --git a/src/test/crush/TestCrushWrapper.cc b/src/test/crush/TestCrushWrapper.cc index 3b2990d76b732..73e0398bc2a70 100644 --- a/src/test/crush/TestCrushWrapper.cc +++ b/src/test/crush/TestCrushWrapper.cc @@ -534,7 +534,7 @@ TEST(CrushWrapper, dump_rules) { delete f; EXPECT_EQ((unsigned)0, ss.str().find("0NAME")); EXPECT_NE(string::npos, - ss.str().find("takedefault")); + ss.str().find("default")); } delete c; diff --git a/src/test/mon/osd-crush.sh b/src/test/mon/osd-crush.sh index efe7fa52864ad..2e42fa6ce7da9 100755 --- a/src/test/mon/osd-crush.sh +++ b/src/test/mon/osd-crush.sh @@ -38,7 +38,7 @@ function run() { function TEST_crush_rule_create_simple() { local dir=$1 ./ceph --format xml osd crush rule dump replicated_ruleset | \ - grep 'takedefault' | \ + egrep 'take[^<]+default' | \ grep 'chooseleaf_firstn0host' || return 1 local ruleset=ruleset0 local root=host1 @@ -48,7 +48,7 @@ function TEST_crush_rule_create_simple() { ./ceph osd crush rule create-simple $ruleset $root $failure_domain 2>&1 | \ grep "$ruleset already exists" || return 1 ./ceph --format xml osd crush rule dump $ruleset | \ - grep 'take'$root'' | \ + egrep 'take[^<]+'$root'' | \ grep 'choose_firstn0'$failure_domain'' || return 1 ./ceph osd crush rule rm $ruleset || return 1 }