diff options
author | Josh Durgin <josh.durgin@inktank.com> | 2013-01-28 16:53:41 -0800 |
---|---|---|
committer | Josh Durgin <josh.durgin@inktank.com> | 2013-01-28 16:53:53 -0800 |
commit | c79f7c6c037bd5653db5342aff7443d99a9c6acd (patch) | |
tree | eecc1bb5af76290deace0d7d7606acadef6c7f78 | |
parent | 26988038e16fa59c461f83b9d00a4f4cebfff6bf (diff) | |
parent | 97b789247ad0652b13ae06ed47bd7b12a5cb5051 (diff) | |
download | ceph-c79f7c6c037bd5653db5342aff7443d99a9c6acd.tar.gz |
Merge branch 'wip-pool-delete'
Reviewed-by: Josh Durgin <josh.durgin@inktank.com>
-rw-r--r-- | doc/man/8/ceph.rst | 2 | ||||
-rw-r--r-- | doc/man/8/rados.rst | 2 | ||||
-rw-r--r-- | doc/rados/operations/control.rst | 4 | ||||
-rw-r--r-- | doc/rados/operations/pools.rst | 2 | ||||
-rw-r--r-- | man/ceph.8 | 4 | ||||
-rw-r--r-- | man/rados.8 | 2 | ||||
-rwxr-xr-x | qa/workunits/mon/pool_ops.sh | 22 | ||||
-rwxr-xr-x | qa/workunits/rbd/copy.sh | 21 | ||||
-rwxr-xr-x | qa/workunits/rbd/permissions.sh | 4 | ||||
-rw-r--r-- | src/mon/OSDMonitor.cc | 37 | ||||
-rw-r--r-- | src/mon/OSDMonitor.h | 3 | ||||
-rw-r--r-- | src/rados.cc | 5 | ||||
-rw-r--r-- | src/test/cli/ceph/help.t | 2 | ||||
-rw-r--r-- | src/tools/ceph.cc | 2 |
14 files changed, 52 insertions, 60 deletions
diff --git a/doc/man/8/ceph.rst b/doc/man/8/ceph.rst index 04b51e609f7..634c82c433e 100644 --- a/doc/man/8/ceph.rst +++ b/doc/man/8/ceph.rst @@ -79,7 +79,7 @@ Monitor commands ================ A more complete summary of commands understood by the monitor cluster can be found in the -wiki, at +online documentation, at http://ceph.com/docs/master/rados/operations/control diff --git a/doc/man/8/rados.rst b/doc/man/8/rados.rst index f6fde9b91a6..e12f2da646a 100644 --- a/doc/man/8/rados.rst +++ b/doc/man/8/rados.rst @@ -65,7 +65,7 @@ Global commands :command:`mkpool` *foo* Create a pool with name foo. -:command:`rmpool` *foo* +:command:`rmpool` *foo* [ *foo* --yes-i-really-really-mean-it ] Delete the pool foo (and all its data) diff --git a/doc/rados/operations/control.rst b/doc/rados/operations/control.rst index db5b8008675..e956c4d9334 100644 --- a/doc/rados/operations/control.rst +++ b/doc/rados/operations/control.rst @@ -237,8 +237,8 @@ Creates/deletes a snapshot of a pool. :: Creates/deletes/renames a storage pool. :: ceph osd pool create {pool-name} pg_num [pgp_num] - ceph osd pool delete {pool-name} - ceph osd pool rename {old-name} {new-name} + ceph osd pool delete {pool-name} [{pool-name} --yes-i-really-really-mean-it] + ceph osd pool rename {old-name} {new-name} Changes a pool setting. :: diff --git a/doc/rados/operations/pools.rst b/doc/rados/operations/pools.rst index a13fa91bcd8..3b492f3862e 100644 --- a/doc/rados/operations/pools.rst +++ b/doc/rados/operations/pools.rst @@ -106,7 +106,7 @@ Delete a Pool To delete a pool, execute:: - ceph osd pool delete {pool-name} + ceph osd pool delete {pool-name} [{pool-name} --yes-i-really-really-mean-it] If you created your own rulesets and rules for a pool you created, you should diff --git a/man/ceph.8 b/man/ceph.8 index 483eb969d8f..b08395423ae 100644 --- a/man/ceph.8 +++ b/man/ceph.8 @@ -104,10 +104,10 @@ ceph pg dump \-o pg.txt .SH MONITOR COMMANDS .sp A more complete summary of commands understood by the monitor cluster can be found in the -wiki, at +online documentation, at .INDENT 0.0 .INDENT 3.5 -\fI\%http://ceph.com/docs/master/cluster-ops/control\fP +\fI\%http://ceph.com/docs/master/rados/operations/control\fP .UNINDENT .UNINDENT .SH AVAILABILITY diff --git a/man/rados.8 b/man/rados.8 index 046ffbf433d..ef65f651e98 100644 --- a/man/rados.8 +++ b/man/rados.8 @@ -90,7 +90,7 @@ counts, over the entire system and broken down by pool. .B \fBmkpool\fP \fIfoo\fP Create a pool with name foo. .TP -.B \fBrmpool\fP \fIfoo\fP +.B \fBrmpool\fP \fIfoo\fP [ \flfoo\fP \-\-yes\-i\-really\-really\-mean\-it ] Delete the pool foo (and all its data) .UNINDENT .SH POOL SPECIFIC COMMANDS diff --git a/qa/workunits/mon/pool_ops.sh b/qa/workunits/mon/pool_ops.sh index 0fed24d7474..2d346cc137f 100755 --- a/qa/workunits/mon/pool_ops.sh +++ b/qa/workunits/mon/pool_ops.sh @@ -7,11 +7,25 @@ ceph osd pool create fooo 123 ceph osd pool create foo 123 # idempotent -ceph osd pool delete foo -ceph osd pool delete foo -ceph osd pool delete fuggg +# should fail due to safety interlock +! ceph osd pool delete foo +! ceph osd pool delete foo foo +! ceph osd pool delete foo foo --force +! ceph osd pool delete foo fooo --yes-i-really-mean-it +! ceph osd pool delete foo --yes-i-really-mean-it foo +! ceph osd pool delete --yes-i-really-mean-it foo foo -ceph osd pool delete fooo + +ceph osd pool delete fooo fooo --yes-i-really-really-mean-it +ceph osd pool delete foo foo --yes-i-really-really-mean-it + +# idempotent +ceph osd pool delete foo foo --yes-i-really-really-mean-it +ceph osd pool delete fooo fooo --yes-i-really-really-mean-it +ceph osd pool delete fooo fooo --yes-i-really-really-mean-it + +# non-existent pool +! ceph osd pool delete fuggg fuggg --yes-i-really-really-mean-it echo OK diff --git a/qa/workunits/rbd/copy.sh b/qa/workunits/rbd/copy.sh index cd0bea79c2c..a3334c073d6 100755 --- a/qa/workunits/rbd/copy.sh +++ b/qa/workunits/rbd/copy.sh @@ -1,5 +1,8 @@ #!/bin/sh -ex +# make sure rbd pool is EMPTY.. this is a test script!! +rbd ls | wc -l | grep -v '^0$' && echo "nonempty rbd pool, aborting! run this script on an empty test cluster only." && exit 1 + IMGS="testimg1 testimg2 testimg3 foo foo2 bar bar2 test1 test2 test3" remove_images() { @@ -90,7 +93,7 @@ test_rename() { ! rbd rename rbd2/bar --dest-pool rbd foo rbd rename --pool rbd2 bar --dest-pool rbd2 foo rbd -p rbd2 ls | grep foo - rados rmpool rbd2 + rados rmpool rbd2 rbd2 --yes-i-really-really-mean-it remove_images } @@ -142,7 +145,7 @@ test_ls() { done for i in $(seq -w 00 99); do - rbd create image.$i --format 2 -s 1 + rbd create image.$i --image-format 2 -s 1 done rbd ls | wc -l | grep 100 rbd ls -l | grep image | wc -l | grep 100 @@ -234,7 +237,7 @@ test_pool_image_args() { echo "testing pool and image args..." remove_images - ceph osd pool delete test || true + ceph osd pool delete test test --yes-i-really-really-mean-it || true ceph osd pool create test 100 truncate -s 1 /tmp/empty @@ -283,8 +286,8 @@ test_pool_image_args() { rbd ls test | grep -qv test12 rm -f /tmp/empty - ceph osd pool delete test - ceph osd pool delete rbd + ceph osd pool delete test test --yes-i-really-really-mean-it + ceph osd pool delete rbd rbd --yes-i-really-really-mean-it ceph osd pool create rbd 100 } @@ -307,9 +310,9 @@ test_clone() { rbd ls -l | grep clone2 | grep rbd2/clone@s1 rbd -p rbd2 ls | grep -v clone2 - rados rmpool rbd2 - rados rmpool rbd - rados mkpool rbd + rados rmpool rbd2 rbd2 --yes-i-really-really-mean-it + rados rmpool rbd rbd --yes-i-really-really-mean-it + rados mkpool rbd rbd --yes-i-really-really-mean-it } test_pool_image_args @@ -319,7 +322,7 @@ test_remove RBD_CREATE_ARGS="" test_others test_locking -RBD_CREATE_ARGS="--format 2" +RBD_CREATE_ARGS="--image-format 2" test_others test_locking test_clone diff --git a/qa/workunits/rbd/permissions.sh b/qa/workunits/rbd/permissions.sh index 40428df38e3..74c24c03c2b 100755 --- a/qa/workunits/rbd/permissions.sh +++ b/qa/workunits/rbd/permissions.sh @@ -6,8 +6,8 @@ create_pools() { } delete_pools() { - (ceph osd pool delete images || true) >/dev/null 2>&1 - (ceph osd pool delete volumes || true) >/dev/null 2>&1 + (ceph osd pool delete images images --yes-i-really-really-mean-it || true) >/dev/null 2>&1 + (ceph osd pool delete volumes volumes --yes-i-really-really-mean-it || true) >/dev/null 2>&1 } diff --git a/src/mon/OSDMonitor.cc b/src/mon/OSDMonitor.cc index 6ab267b0efb..3d11cfffc0f 100644 --- a/src/mon/OSDMonitor.cc +++ b/src/mon/OSDMonitor.cc @@ -61,7 +61,6 @@ static ostream& _prefix(std::ostream *_dout, Monitor *mon, OSDMap& osdmap) { /************ MAPS ****************/ OSDMonitor::OSDMonitor(Monitor *mn, Paxos *p) : PaxosService(mn, p), - delete_pool_nonce(0), thrash_map(0), thrash_last_up_osd(-1) { // we need to trim this too @@ -2796,44 +2795,22 @@ bool OSDMonitor::prepare_command(MMonCommand *m) paxos->wait_for_commit(new Monitor::C_Command(mon, m, 0, rs, paxos->get_version())); return true; } else if (m->cmd[2] == "delete" && m->cmd.size() >= 4) { - // osd pool delete <poolname> <poolname again> <nonce> - // hey, let's delete a pool! + // osd pool delete <poolname> <poolname again> --yes-i-really-really-mean-it int64_t pool = osdmap.lookup_pg_pool_name(m->cmd[3].c_str()); if (pool < 0) { ss << "pool '" << m->cmd[3] << "' does not exist"; err = 0; goto out; } - if (m->cmd.size() < 6) { - delete_pool_nonce = rand(); - delete_pool_nonce_timeout = ceph_clock_now(g_ceph_context); - delete_pool_nonce_timeout += 30; - ss << "WARNING: this will efficiently **DESTROY** an entire pool of data. if you are ABSOLUTELY CERTAIN" - << " that this is what you want to do, retry listing the pool name twice, followed by " << delete_pool_nonce - << " within 30 seconds."; - err = -EPERM; - goto out; - } - assert(m->cmd.size() >= 6); - if (m->cmd[4] != m->cmd[3]) { - ss << "ERROR: you must list the pool name you want to **DESTROY** twice"; - err = -EPERM; - goto out; - } - unsigned safety = atol(m->cmd[5].c_str()); - if (safety != delete_pool_nonce) { - ss << "ERROR: did not confirm pool deletion with correct confirmation; " << safety << " != " << delete_pool_nonce << "; try again"; - err = -EPERM; - goto out; - } - if (ceph_clock_now(g_ceph_context) > delete_pool_nonce_timeout) { - ss << "ERROR: did not confirm pool deletion within 30 seconds; try again"; + if (m->cmd.size() != 6 || + m->cmd[3] != m->cmd[4] || + m->cmd[5] != "--yes-i-really-really-mean-it") { + ss << "WARNING: this will *PERMANENTLY DESTROY* all data stored in pool " << m->cmd[3] + << ". If you are *ABSOLUTELY CERTAIN* that is what you want, pass the pool name *twice*, " + << "followed by --yes-i-really-really-mean-it."; err = -EPERM; goto out; } - assert(safety == delete_pool_nonce); - delete_pool_nonce = 0; - delete_pool_nonce_timeout = utime_t(); int ret = _prepare_remove_pool(pool); if (ret == 0) ss << "pool '" << m->cmd[3] << "' deleted"; diff --git a/src/mon/OSDMonitor.h b/src/mon/OSDMonitor.h index e389c65e825..9529f731c84 100644 --- a/src/mon/OSDMonitor.h +++ b/src/mon/OSDMonitor.h @@ -123,9 +123,6 @@ private: map<int,double> osd_weight; - unsigned delete_pool_nonce; // safety interlock for removing pools - utime_t delete_pool_nonce_timeout; - void check_failures(utime_t now); bool check_failure(utime_t now, int target_osd, failure_info_t& fi); diff --git a/src/rados.cc b/src/rados.cc index 0b012c5972b..a850f874ac2 100644 --- a/src/rados.cc +++ b/src/rados.cc @@ -58,7 +58,8 @@ void usage(ostream& out) " mkpool <pool-name> [123[ 4]] create pool <pool-name>'\n" " [with auid 123[and using crush rule 4]]\n" " cppool <pool-name> <dest-pool> copy content of a pool\n" -" rmpool <pool-name> remove pool <pool-name>'\n" +" rmpool <pool-name> [<pool-name> --yes-i-really-really-mean-it]\n" +" remove pool <pool-name>'\n" " df show per-pool and total usage\n" " ls list objects in pool\n\n" " chown 123 change the pool owner to auid 123\n" @@ -1799,7 +1800,7 @@ static int rados_tool_common(const std::map < std::string, std::string > &opts, strcmp(nargs[1], nargs[2]) != 0 || strcmp(nargs[3], "--yes-i-really-really-mean-it") != 0) { cerr << "WARNING:\n" - << " This will PERMANENTLY DESTROY an entire pool of object with no way back.\n" + << " This will PERMANENTLY DESTROY an entire pool of objects with no way back.\n" << " To confirm, pass the pool to remove twice, followed by\n" << " --yes-i-really-really-mean-it" << std::endl; cout << nargs << std::endl; diff --git a/src/test/cli/ceph/help.t b/src/test/cli/ceph/help.t index e8afdaf7d35..186490aebd4 100644 --- a/src/test/cli/ceph/help.t +++ b/src/test/cli/ceph/help.t @@ -56,7 +56,7 @@ ceph osd pool mksnap <pool> <snapname> ceph osd pool rmsnap <pool> <snapname> ceph osd pool create <pool> <pg_num> [<pgp_num>] - ceph osd pool delete <pool> + ceph osd pool delete <pool> [<pool> --yes-i-really-really-mean-it] ceph osd pool rename <pool> <new pool name> ceph osd pool set <pool> <field> <value> ceph osd scrub <osd-id> diff --git a/src/tools/ceph.cc b/src/tools/ceph.cc index 7582ac96ab2..c99d8624978 100644 --- a/src/tools/ceph.cc +++ b/src/tools/ceph.cc @@ -99,7 +99,7 @@ static void usage() cout << " ceph osd pool mksnap <pool> <snapname>\n"; cout << " ceph osd pool rmsnap <pool> <snapname>\n"; cout << " ceph osd pool create <pool> <pg_num> [<pgp_num>]\n"; - cout << " ceph osd pool delete <pool>\n"; + cout << " ceph osd pool delete <pool> [<pool> --yes-i-really-really-mean-it]\n"; cout << " ceph osd pool rename <pool> <new pool name>\n"; cout << " ceph osd pool set <pool> <field> <value>\n"; cout << " ceph osd scrub <osd-id>\n"; |