]> git.apps.os.sepia.ceph.com Git - ceph-ci.git/commitdiff
osdmaptool: require --upmap-save before modifying input osdmap
authorSage Weil <sage@redhat.com>
Tue, 23 May 2017 21:56:14 +0000 (17:56 -0400)
committerSage Weil <sage@redhat.com>
Tue, 23 May 2017 21:56:14 +0000 (17:56 -0400)
IMO it is dangerous to modify the provided osdmap in this case unless the
user explicitly asks for it.  This was super annoying while I was testing
this code.

Signed-off-by: Sage Weil <sage@redhat.com>
src/test/cli/osdmaptool/help.t
src/test/cli/osdmaptool/missing-argument.t
src/test/cli/osdmaptool/upmap.t
src/tools/osdmaptool.cc

index 69374a82dfa0053674914765306a6450bc67b111..c7fff989b83873c11a29c83f3f06e0d268a535ac 100644 (file)
@@ -19,4 +19,5 @@
      --upmap-deviation <max-deviation>
                              max deviation from target [default: .01]
      --upmap-pool <poolname> restrict upmap balancing to 1 or more pools
+     --upmap-save            write modified OSDMap with upmap changes
   [1]
index 9c7c65631279a46b57fde4bc4a2d42f77d681dc5..9ca73052c78f80f6b69fa204ee58a4d71832be50 100644 (file)
@@ -19,4 +19,5 @@
      --upmap-deviation <max-deviation>
                              max deviation from target [default: .01]
      --upmap-pool <poolname> restrict upmap balancing to 1 or more pools
+     --upmap-save            write modified OSDMap with upmap changes
   [1]
index c833da3991ff801a997f87332e923a2644fc2bcf..b79bf86a0d51cda70aee94a4d0de7c5ed668cf0f 100644 (file)
@@ -7,7 +7,6 @@
   writing upmap command output to: c
   checking for upmap cleanups
   upmap, max-count 11, max deviation 0.01
-  osdmaptool: writing epoch 3 to om
   $ cat c
   ceph osd pg-upmap-items 0.3 54 52 156 155
   ceph osd pg-upmap-items 0.1b 158 155 231 227 143 142
index 2738412e538d1f4f167ca9c5cf17eac8a23d27d0..ab6346f80f301aa80cbfb413dcc5020c80aac574 100644 (file)
@@ -46,6 +46,7 @@ void usage()
   cout << "   --upmap-deviation <max-deviation>" << std::endl;
   cout << "                           max deviation from target [default: .01]" << std::endl;
   cout << "   --upmap-pool <poolname> restrict upmap balancing to 1 or more pools" << std::endl;
+  cout << "   --upmap-save            write modified OSDMap with upmap changes" << std::endl;
   exit(1);
 }
 
@@ -117,6 +118,7 @@ int main(int argc, const char **argv)
   bool test_random = false;
   bool upmap_cleanup = false;
   bool upmap = false;
+  bool upmap_save = false;
   std::string upmap_file = "-";
   int upmap_max = 100;
   float upmap_deviation = .01;
@@ -145,6 +147,8 @@ int main(int argc, const char **argv)
       }
     } else if (ceph_argparse_witharg(args, i, &upmap_file, "--upmap-cleanup", (char*)NULL)) {
       upmap_cleanup = true;
+    } else if (ceph_argparse_witharg(args, i, &upmap_file, "--upmap-save", (char*)NULL)) {
+      upmap_save = true;
     } else if (ceph_argparse_witharg(args, i, &upmap_file, "--upmap", (char*)NULL)) {
       upmap_cleanup = true;
       upmap = true;
@@ -350,9 +354,11 @@ int main(int argc, const char **argv)
       &pending_inc);
     if (changed) {
       print_inc_upmaps(pending_inc, upmap_fd);
-      int r = osdmap.apply_incremental(pending_inc);
-      assert(r == 0);
-      modified = true;
+      if (upmap_save) {
+       int r = osdmap.apply_incremental(pending_inc);
+       assert(r == 0);
+       modified = true;
+      }
     } else {
       cout << "no upmaps proposed" << std::endl;
     }