]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
CrushWrapper: pick a ruleset same as rule_id 4095/head
authorXiaoxi Chen <xiaoxi.chen@intel.com>
Wed, 20 Aug 2014 07:35:44 +0000 (15:35 +0800)
committerLoic Dachary <ldachary@redhat.com>
Thu, 19 Mar 2015 09:36:30 +0000 (10:36 +0100)
Originally in the add_simple_ruleset funtion, the ruleset_id
is not reused but rule_id is reused. So after some add/remove
against rules, the newly created rule likely to have
ruleset!=rule_id.

We dont want this happen because we are trying to hold the constraint
that ruleset == rule_id.

Signed-off-by: Xiaoxi Chen <xiaoxi.chen@intel.com>
(cherry picked from commit 78e84f34da83abf5a62ae97bb84ab70774b164a6)

src/test/mon/osd-crush.sh

index 56c85735df2f9317a4957f4dc2702b0cfb188d99..8aae18db6c0376e3bbf434a49b195b7c8b148d6f 100755 (executable)
@@ -175,6 +175,61 @@ EOF
 
 }
 
+function Check_ruleset_id_match_rule_id() {
+    local rule_name=$1
+    rule_id=`./ceph osd crush rule dump $rule_name | grep "\"rule_id\":" | awk -F ":|," '{print int($2)}'`
+    ruleset_id=`./ceph osd crush rule dump $rule_name | grep "\"ruleset\":"| awk -F ":|," '{print int($2)}'`
+    test $ruleset_id = $rule_id || return 1
+}
+
+function generate_manipulated_rules() {
+    local dir=$1
+    ./ceph osd crush add-bucket $root host
+    ./ceph osd crush rule create-simple test_rule1 $root osd firstn || return 1
+    ./ceph osd crush rule create-simple test_rule2 $root osd firstn || return 1
+    ./ceph osd getcrushmap -o $dir/original_map
+    ./crushtool -d $dir/original_map -o $dir/decoded_original_map
+    #manipulate the rulesets , to make the rule_id != ruleset_id
+    sed -i 's/ruleset 0/ruleset 3/' $dir/decoded_original_map
+    sed -i 's/ruleset 2/ruleset 0/' $dir/decoded_original_map
+    sed -i 's/ruleset 1/ruleset 2/' $dir/decoded_original_map
+
+    ./crushtool -c $dir/decoded_original_map -o $dir/new_map
+    ./ceph osd setcrushmap -i $dir/new_map
+
+    ./ceph osd crush rule dump
+}
+
+function TEST_crush_ruleset_match_rule_when_creating() {
+    local dir=$1
+    local root=host1
+
+    generate_manipulated_rules $dir
+
+    ./ceph osd crush rule create-simple special_rule_simple $root osd firstn || return 1
+
+    ./ceph osd crush rule dump
+    #show special_rule_simple has same rule_id and ruleset_id
+    Check_ruleset_id_match_rule_id special_rule_simple || return 1
+}
+
+function TEST_add_ruleset_failed() {
+    local dir=$1
+    local root=host1
+
+    ./ceph osd crush add-bucket $root host
+    ./ceph osd crush rule create-simple test_rule1 $root osd firstn || return 1
+    ./ceph osd crush rule create-simple test_rule2 $root osd firstn || return 1
+    #./ceph osd crush rule rm test_rule1
+    for i in `seq 3 255`
+    do
+      ./ceph osd crush rule create-simple test_rule$i $root osd firstn || return 1
+      Check_ruleset_id_match_rule_id test_rule$i || return 1
+    done
+
+    ./ceph osd crush rule create-simple test_rule_nospace $root osd firstn 2>&1 | grep "Error ENOSPC" || return 1
+
+}
 main osd-crush
 
 # Local Variables: