]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
crushtool: enable check against max_id
authorKefu Chai <kchai@redhat.com>
Tue, 26 May 2015 07:35:10 +0000 (15:35 +0800)
committerKefu Chai <kchai@redhat.com>
Fri, 10 Jul 2015 07:40:01 +0000 (15:40 +0800)
add an argument "max_id" for "--check-names" to check if any item
has an id greater or equal to given "max_id" in crush map.

Note: edited since we do not have the fix introduced in 46103b2 in
      hammer.

Signed-off-by: Kefu Chai <kchai@redhat.com>
(cherry picked from commit d0658dd3cdf072b2a7c2a1986f8785a697c591ee)

src/test/cli/crushtool/check-names.empty.t
src/test/cli/crushtool/check-names.max-id.t [new file with mode: 0644]
src/test/cli/crushtool/help.t
src/tools/crushtool.cc

index 9e30790ca316d7d158e866281732a81509b07749..755e9317b910c16ceaa6ce24fe8420daea016e86 100644 (file)
@@ -1,4 +1,5 @@
   $ crushtool -c "$TESTDIR/check-names.empty.crushmap.txt" -o "$TESTDIR/check-names.empty.crushmap"
-  $ crushtool -i "$TESTDIR/check-names.empty.crushmap" --check-names
+  $ crushtool -i "$TESTDIR/check-names.empty.crushmap" --check 0
   unknown type name: item#0
+  [1]
   $ rm -f "$TESTDIR/check-names.empty.crushmap"
diff --git a/src/test/cli/crushtool/check-names.max-id.t b/src/test/cli/crushtool/check-names.max-id.t
new file mode 100644 (file)
index 0000000..0fa5c01
--- /dev/null
@@ -0,0 +1,7 @@
+  $ crushtool -i "$TESTDIR/simple.template" --add-item 0 1.0 device0 --loc host host0 --loc cluster cluster0 -o check-names.crushmap > /dev/null
+  $ crushtool -i check-names.crushmap       --add-item 1 1.0 device1 --loc host host0 --loc cluster cluster0 -o check-names.crushmap > /dev/null
+  $ crushtool -i check-names.crushmap --check-names=2
+  $ crushtool -i check-names.crushmap       --add-item 2 1.0 device2 --loc host host0 --loc cluster cluster0 -o check-names.crushmap > /dev/null
+  $ crushtool -i check-names.crushmap --check-names=2
+  item id too large: item#2
+  [1]
index 784c6275c4fba72ae736e7054c2a1d378f9305fb..ab54bd5a5122ba60d238afde04b4d701d263d7cb 100644 (file)
@@ -33,7 +33,8 @@
   
   Options for the display/test stage
   
-     --check-names         check if any item is referencing an unknown name/type
+     --check-names max_id
+                           check if any item is referencing an unknown name/type
      -i mapfn --show-location id
                            show location for given device id
      --show-utilization    show OSD usage
index c8cf24ce632aca4976d5cc70816e0246aab059ce..4881b0ae3c04e6bbce0dc0a0afa35e2c6c4b0ad8 100644 (file)
@@ -138,7 +138,8 @@ void usage()
   cout << "\n";
   cout << "Options for the display/test stage\n";
   cout << "\n";
-  cout << "   --check-names         check if any item is referencing an unknown name/type\n";
+  cout << "   --check-names max_id\n";
+  cout << "                         check if any item is referencing an unknown name/type\n";
   cout << "   -i mapfn --show-location id\n";
   cout << "                         show location for given device id\n";
   cout << "   --show-utilization    show OSD usage\n";
@@ -196,6 +197,7 @@ int main(int argc, const char **argv)
   bool compile = false;
   bool decompile = false;
   bool check_names = false;
+  int max_id = -1;
   bool test = false;
   bool display = false;
   bool tree = false;
@@ -281,7 +283,7 @@ int main(int argc, const char **argv)
     } else if (ceph_argparse_witharg(args, i, &val, "-c", "--compile", (char*)NULL)) {
       srcfn = val;
       compile = true;
-    } else if (ceph_argparse_flag(args, i, "--check-names", (char*)NULL)) {
+    } else if (ceph_argparse_withint(args, i, &max_id, &err, "--check-names", (char*)NULL)) {
       check_names = true;
     } else if (ceph_argparse_flag(args, i, "-t", "--test", (char*)NULL)) {
       test = true;
@@ -794,7 +796,7 @@ int main(int argc, const char **argv)
   }
 
  if (modified) {
-    crush.finalize();
+   crush.finalize();
 
     if (outfn.empty()) {
       cout << me << " successfully built or modified map.  Use '-o <file>' to write it out." << std::endl;
@@ -812,7 +814,7 @@ int main(int argc, const char **argv)
   }
 
   if (check_names) {
-    if (!tester.check_name_maps()) {
+    if (!tester.check_name_maps(max_id)) {
       exit(1);
     }
   }