]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
mon/OSDMonitor.cc: fix expected_num_objects interpret error 22050/head
authorYang Honggang <joseph.yang@xtaotech.com>
Mon, 22 Jan 2018 02:00:17 +0000 (21:00 -0500)
committerKefu Chai <kchai@redhat.com>
Thu, 17 May 2018 13:16:00 +0000 (21:16 +0800)
Fixes: http://tracker.ceph.com/issues/22530
Signed-off-by: Yang Honggang <joseph.yang@xtaotech.com>
(cherry picked from commit c24f2baec968ff66e792991d829591505ffba3ae)

Conflicts:
qa/standalone/mon/osd-pool-create.sh: jewel does not have
qa/standalone tests by then. and in jewel, "ruleset" is not renamed to
"rule" yet.
src/mon/OSDMonitor.cc
src/pybind/mgr/localpool/module.py: trivial resolution

src/mon/OSDMonitor.cc
src/test/mon/osd-pool-create.sh

index f000480194f7e2a7005a0e636857067c5cb41bfb..68cc2537e045e40017b7c2544592012742306019 100644 (file)
@@ -7010,6 +7010,7 @@ done:
     }
 
     bool implicit_ruleset_creation = false;
+    int64_t expected_num_objects = 0;
     string ruleset_name;
     cmd_getval(g_ceph_context, cmdmap, "ruleset", ruleset_name);
     string erasure_code_profile;
@@ -7047,9 +7048,25 @@ done:
          ruleset_name = poolstr;
        }
       }
+      cmd_getval(g_ceph_context, cmdmap, "expected_num_objects",
+                 expected_num_objects, int64_t(0));
     } else {
       //NOTE:for replicated pool,cmd_map will put ruleset_name to erasure_code_profile field
-      ruleset_name = erasure_code_profile;
+      if (erasure_code_profile != "") { // cmd is from CLI
+        if (ruleset_name != "") {
+          string interr;
+          expected_num_objects = strict_strtoll(ruleset_name.c_str(), 10, &interr);
+          if (interr.length()) {
+            ss << "error parsing integer value '" << ruleset_name << "': " << interr;
+            err = -EINVAL;
+            goto reply;
+          }
+        }
+        ruleset_name = erasure_code_profile;
+      } else { // cmd is well-formed
+        cmd_getval(g_ceph_context, cmdmap, "expected_num_objects",
+                   expected_num_objects, int64_t(0));
+      }
     }
 
     if (!implicit_ruleset_creation && ruleset_name != "") {
@@ -7063,8 +7080,6 @@ done:
        goto reply;
     }
 
-    int64_t expected_num_objects;
-    cmd_getval(g_ceph_context, cmdmap, "expected_num_objects", expected_num_objects, int64_t(0));
     if (expected_num_objects < 0) {
       ss << "'expected_num_objects' must be non-negative";
       err = -EINVAL;
index 4a19d13410b8e19f32d8054cedea95a4bb393f81..3b5b5163fd2a3a916fa7e2e215c30affba9adc20 100755 (executable)
@@ -22,9 +22,9 @@ function run() {
     shift
 
     export CEPH_MON="127.0.0.1:7105" # git grep '\<7105\>' : there must be only one
-    export CEPH_ARGS
     CEPH_ARGS+="--fsid=$(uuidgen) --auth-supported=none "
     CEPH_ARGS+="--mon-host=$CEPH_MON "
+    export CEPH_ARGS
 
     local funcs=${@:-$(set | sed -n -e 's/^\(TEST_[0-9a-z_]*\) .*/\1/p')}
     for func in $funcs ; do
@@ -285,6 +285,30 @@ function TEST_utf8_cli() {
     ceph osd pool delete 黄 黄 --yes-i-really-really-mean-it
 }
 
+function TEST_pool_create_rep_expected_num_objects() {
+    local dir=$1
+    setup $dir || return 1
+
+    # disable pg dir merge
+    CEPH_ARGS+="--filestore-merge-threshold=-10 "
+    export CEPH_ARGS
+    run_mon $dir a || return 1
+    run_osd $dir 0 || return 1
+
+    local expected_num_objects=100000
+    ceph osd pool create rep_expected_num_objects 64 64 replicated replicated_ruleset $expected_num_objects || return 1
+    # wait for pg dir creating
+    sleep 5
+    local ret=$(ceph osd pool ls detail --format=xml -c td/osd-pool-create/ceph.conf | \
+        xmlstarlet sel -t -m "//pool[./pool_name='rep_expected_num_objects']/expected_num_objects"  -v .)
+    if [ "$ret" -eq $expected_num_objects ];
+    then
+        echo "TEST_pool_create_rep_expected_num_objects PASS"
+    else
+        return 1
+    fi
+}
+
 main osd-pool-create "$@"
 
 # Local Variables: