]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
mon/OSDMonitor: add flag `--yes-i-really-mean-it` for setting pool size 1 33281/head
authorDeepika Upadhyay <dupadhya@redhat.com>
Wed, 12 Feb 2020 14:38:29 +0000 (20:08 +0530)
committerDeepika Upadhyay <dupadhya@redhat.com>
Mon, 9 Mar 2020 17:57:36 +0000 (23:27 +0530)
Adds option `mon_allow_pool_size_one` which will be disabled by default
to ensure pools are not configured without replicas.
If the user still wants to use pool size 1, they will have to change the
value of `mon_allow_pool_size_one` to true and then have to pass flag
`--yes-i-really-mean-it` to cli command:

Example:
`ceph osd pool test set size 1 --yes-i-really-mean-it`

Fixes: https://tracker.ceph.com/issues/44025
Signed-off-by: Deepika Upadhyay <dupadhya@redhat.com>
18 files changed:
PendingReleaseNotes
qa/standalone/ceph-helpers.sh
qa/standalone/mon/health-mute.sh
qa/standalone/osd/osd-backfill-prio.sh
qa/standalone/osd/osd-backfill-space.sh
qa/standalone/osd/osd-backfill-stats.sh
qa/standalone/osd/osd-recovery-prio.sh
qa/standalone/osd/osd-recovery-space.sh
qa/standalone/osd/osd-recovery-stats.sh
qa/tasks/ceph.conf.template
qa/workunits/ceph-helpers-root.sh
qa/workunits/cephtool/test.sh
qa/workunits/mon/pool_ops.sh
qa/workunits/rados/test_alloc_hint.sh
src/common/options.cc
src/mon/OSDMonitor.cc
src/test/test_lost.sh
src/vstart.sh

index c9fd4c79451858ebfc14b45b83b3ef7b8fc09050..cffac983c11ece41664a8fde2b537df283bb16b5 100644 (file)
   If the zonegroup is part of a realm, the change must be committed with
   'radosgw-admin period update --commit' - otherwise the change will take
   effect after radosgws are restarted.
+
+* Monitors now have config option ``mon_allow_pool_size_one``, which is disabled
+  by default. However, if enabled, user now have to pass the
+  ``--yes-i-really-mean-it`` flag to ``osd pool set size 1``, if they are really
+  sure of configuring pool size 1.
index 19fede19480293d2dadcf9e04d80b4d25be071ad..1d4aa4e5fb35a1dc64154777af35a7cc28f2d0c8 100755 (executable)
@@ -478,6 +478,7 @@ function run_mon() {
         --run-dir=$dir \
         --pid-file=$dir/\$name.pid \
        --mon-allow-pool-delete \
+       --mon-allow-pool-size-one \
        --osd-pool-default-pg-autoscale-mode off \
        --mon-osd-backfillfull-ratio .99 \
         "$@" || return 1
index a255798b82fbd05fb269f033af04ed938dcef924..d8e07ca061bb26f8e0115deece1d46fa62e0e725 100755 (executable)
@@ -38,7 +38,7 @@ function TEST_mute() {
     ceph -s
     ceph health | grep HEALTH_OK || return 1
     # test warning on setting pool size=1
-    ceph osd pool set foo size 1
+    ceph osd pool set foo size 1 --yes-i-really-mean-it
     ceph -s
     ceph health | grep HEALTH_WARN || return 1
     ceph health detail | grep POOL_NO_REDUNDANCY || return 1
index a089696bb9b4d8bf665092da9ffff82443599fd3..c8c05ce19fb95b8e5bb6902789397956d50997fa 100755 (executable)
@@ -129,8 +129,8 @@ function TEST_backfill_priority() {
       fi
     done
 
-    ceph osd pool set $pool2 size 1
-    ceph osd pool set $pool3 size 1
+    ceph osd pool set $pool2 size 1 --yes-i-really-mean-it
+    ceph osd pool set $pool3 size 1 --yes-i-really-mean-it
     wait_for_clean || return 1
 
     dd if=/dev/urandom of=$dir/data bs=1M count=10
@@ -405,9 +405,9 @@ function TEST_backfill_pool_priority() {
     pool1_prio=$(expr $DEGRADED_PRIO + 1 + $pool1_extra_prio)
     pool2_prio=$(expr $DEGRADED_PRIO + 1 + $pool2_extra_prio)
 
-    ceph osd pool set $pool1 size 1
+    ceph osd pool set $pool1 size 1 --yes-i-really-mean-it
     ceph osd pool set $pool1 recovery_priority $pool1_extra_prio
-    ceph osd pool set $pool2 size 1
+    ceph osd pool set $pool2 size 1 --yes-i-really-mean-it
     ceph osd pool set $pool2 recovery_priority $pool2_extra_prio
     wait_for_clean || return 1
 
index 3978668eae23c8bdd07a7c84213d3b8b7feba851..b2a1a821fdb245e92c020b179904534a764d4d02 100755 (executable)
@@ -124,7 +124,7 @@ function TEST_backfill_test_simple() {
     for p in $(seq 1 $pools)
     do
       create_pool "${poolprefix}$p" 1 1
-      ceph osd pool set "${poolprefix}$p" size 1
+      ceph osd pool set "${poolprefix}$p" size 1 --yes-i-really-mean-it
     done
 
     wait_for_clean || return 1
@@ -206,7 +206,7 @@ function TEST_backfill_test_multi() {
     for p in $(seq 1 $pools)
     do
       create_pool "${poolprefix}$p" 1 1
-      ceph osd pool set "${poolprefix}$p" size 1
+      ceph osd pool set "${poolprefix}$p" size 1 --yes-i-really-mean-it
     done
 
     wait_for_clean || return 1
@@ -364,8 +364,8 @@ function TEST_backfill_test_sametarget() {
       fi
     done
 
-    ceph osd pool set $pool1 size 1
-    ceph osd pool set $pool2 size 1
+    ceph osd pool set $pool1 size 1 --yes-i-really-mean-it
+    ceph osd pool set $pool2 size 1 --yes-i-really-mean-it
 
     wait_for_clean || return 1
 
@@ -444,7 +444,7 @@ function TEST_backfill_multi_partial() {
 
     ceph osd set-require-min-compat-client luminous
     create_pool fillpool 1 1
-    ceph osd pool set fillpool size 1
+    ceph osd pool set fillpool size 1 --yes-i-really-mean-it
     for p in $(seq 1 $pools)
     do
       create_pool "${poolprefix}$p" 1 1
@@ -639,7 +639,7 @@ function TEST_ec_backfill_simple() {
 
     ceph osd set-backfillfull-ratio .85
     create_pool fillpool 1 1
-    ceph osd pool set fillpool size 1
+    ceph osd pool set fillpool size 1 --yes-i-really-mean-it
 
     # Partially fill an osd
     # We have room for 200 18K replicated objects, if we create 13K objects
@@ -770,7 +770,7 @@ function TEST_ec_backfill_multi() {
 
     ceph osd set-require-min-compat-client luminous
     create_pool fillpool 1 1
-    ceph osd pool set fillpool size 1
+    ceph osd pool set fillpool size 1 --yes-i-really-mean-it
 
     # Partially fill an osd
     # We have room for 200 18K replicated objects, if we create 9K objects
@@ -888,7 +888,7 @@ function SKIP_TEST_ec_backfill_multi_partial() {
 
     ceph osd set-require-min-compat-client luminous
     create_pool fillpool 1 1
-    ceph osd pool set fillpool size 1
+    ceph osd pool set fillpool size 1 --yes-i-really-mean-it
     # last osd
     ceph osd pg-upmap 1.0 $lastosd
 
@@ -1010,7 +1010,7 @@ function SKIP_TEST_ec_backfill_multi_partial() {
 
     ceph osd set-require-min-compat-client luminous
     create_pool fillpool 1 1
-    ceph osd pool set fillpool size 1
+    ceph osd pool set fillpool size 1 --yes-i-really-mean-it
 
     # Partially fill an osd
     # We have room for 200 48K ec objects, if we create 4k replicated objects
index ea43b00fe462598a0f1cb5712b0a6fdeba57eded..26335678c659e870afe3c7a9ad621468afa33660 100755 (executable)
@@ -143,7 +143,7 @@ function TEST_backfill_sizeup() {
     run_osd $dir 5 || return 1
 
     create_pool $poolname 1 1
-    ceph osd pool set $poolname size 1
+    ceph osd pool set $poolname size 1 --yes-i-really-mean-it
 
     wait_for_clean || return 1
 
@@ -189,7 +189,7 @@ function TEST_backfill_sizeup_out() {
     run_osd $dir 5 || return 1
 
     create_pool $poolname 1 1
-    ceph osd pool set $poolname size 1
+    ceph osd pool set $poolname size 1 --yes-i-really-mean-it
 
     wait_for_clean || return 1
 
index fb386e265ab3525dce0b5cb0748f1a1a4c840964..672b407de900dc977e778b35f9e293d85b24106c 100755 (executable)
@@ -125,8 +125,8 @@ function TEST_recovery_priority() {
       fi
     done
 
-    ceph osd pool set $pool2 size 1
-    ceph osd pool set $pool3 size 1
+    ceph osd pool set $pool2 size 1 --yes-i-really-mean-it
+    ceph osd pool set $pool3 size 1 --yes-i-really-mean-it
     wait_for_clean || return 1
 
     dd if=/dev/urandom of=$dir/data bs=1M count=10
@@ -401,9 +401,9 @@ function TEST_recovery_pool_priority() {
     pool1_prio=$(expr $NORMAL_PRIO + $pool1_extra_prio)
     pool2_prio=$(expr $NORMAL_PRIO + $pool2_extra_prio)
 
-    ceph osd pool set $pool1 size 1
+    ceph osd pool set $pool1 size 1 --yes-i-really-mean-it
     ceph osd pool set $pool1 recovery_priority $pool1_extra_prio
-    ceph osd pool set $pool2 size 1
+    ceph osd pool set $pool2 size 1 --yes-i-really-mean-it
     ceph osd pool set $pool2 recovery_priority $pool2_extra_prio
     wait_for_clean || return 1
 
index 82cdf82e5733a065789f928a346a2c5171e1a71d..07ed09b4380fa0ad41c350287ddbcf952a387bae 100755 (executable)
@@ -105,7 +105,7 @@ function TEST_recovery_test_simple() {
     for p in $(seq 1 $pools)
     do
       create_pool "${poolprefix}$p" 1 1
-      ceph osd pool set "${poolprefix}$p" size 1
+      ceph osd pool set "${poolprefix}$p" size 1 --yes-i-really-mean-it
     done
 
     wait_for_clean || return 1
index b6955bb4c60cd0dfa4a26908eb37a07d79864369..7d88e98a0c09e4844ebeb5e4fa35d29c41617305 100755 (executable)
@@ -314,7 +314,7 @@ function TEST_recovery_undersized() {
     done
 
     create_pool $poolname 1 1
-    ceph osd pool set $poolname size 1
+    ceph osd pool set $poolname size 1 --yes-i-really-mean-it
 
     wait_for_clean || return 1
 
index 493eacb32caa3d0fbbb397cb767ac539efa6d352..6eff6e339a0c7494ddaf9d808756363cf4770e83 100644 (file)
@@ -30,6 +30,7 @@
        mon warn on too few osds = false
        mon_warn_on_pool_pg_num_not_power_of_two = false
         mon_warn_on_pool_no_redundancy = false
+       mon_allow_pool_size_one = true
 
         osd pool default erasure code profile = "plugin=jerasure technique=reed_sol_van k=2 m=1 ruleset-failure-domain=osd crush-failure-domain=osd"
 
index 934380e5c47539567244ed6b69f29f7cacbd8300..c8fa4a3fe41d83bb85ef12b7685fa333d44d338a 100755 (executable)
@@ -108,7 +108,7 @@ function pool_read_write() {
 
     ceph osd pool delete $test_pool $test_pool --yes-i-really-really-mean-it || return 1
     ceph osd pool create $test_pool 4 || return 1
-    ceph osd pool set $test_pool size $size || return 1
+    ceph osd pool set $test_pool size $size --yes-i-really-mean-it || return 1
     ceph osd pool set $test_pool min_size $size || return 1
     ceph osd pool application enable $test_pool rados
 
index 51d8bd7c7bc3e9599c4563585e01410448f2f2d1..16d8fa551e4804c01bd61be198cd858b28f49c05 100755 (executable)
@@ -2174,9 +2174,9 @@ function test_mon_osd_pool_set()
 
   old_size=$(ceph osd pool get $TEST_POOL_GETSET size | sed -e 's/size: //')
   (( new_size = old_size + 1 ))
-  ceph osd pool set $TEST_POOL_GETSET size $new_size
+  ceph osd pool set $TEST_POOL_GETSET size $new_size --yes-i-really-mean-it
   ceph osd pool get $TEST_POOL_GETSET size | grep "size: $new_size"
-  ceph osd pool set $TEST_POOL_GETSET size $old_size
+  ceph osd pool set $TEST_POOL_GETSET size $old_size --yes-i-really-mean-it
 
   ceph osd pool create pool_erasure 1 1 erasure
   ceph osd pool application enable pool_erasure rados
index 4098795b98923171a11ae7038b07cca964288348..198a65869c7c9353e1a8a88a0bbacfd590590ce3 100755 (executable)
@@ -19,7 +19,7 @@ ceph osd pool create foooo 123
 
 ceph osd pool create foo 123 # idempotent
 
-ceph osd pool set foo size 1
+ceph osd pool set foo size 1 --yes-i-really-mean-it
 ceph osd pool set foo size 4
 ceph osd pool set foo size 10
 expect_false ceph osd pool set foo size 0
index 2323915fce74bcf80ea79d9d2924d19bfc753c31..535201ca3c455ddf474a6caabec80131f86c1a52 100755 (executable)
@@ -109,7 +109,7 @@ setup_osd_data
 
 POOL="alloc_hint-rep"
 ceph osd pool create "${POOL}" "${NUM_PG}"
-ceph osd pool set "${POOL}" size "${NUM_OSDS}"
+ceph osd pool set "${POOL}" size "${NUM_OSDS}" --yes-i-really-mean-it
 ceph osd pool application enable "${POOL}" rados
 
 OBJ="foo"
index 449e5ea585c456866be03a5a8defcfc6457e5e80..54c70e8b4fee9756c8085b5abf186a68230c7978 100644 (file)
@@ -1736,6 +1736,11 @@ std::vector<Option> get_global_options() {
     .add_see_also("osd_pool_default_size")
     .add_see_also("osd_pool_default_min_size"),
 
+    Option("mon_allow_pool_size_one", Option::TYPE_BOOL, Option::LEVEL_ADVANCED)
+    .set_default(false)
+    .add_service("mon")
+    .set_description("allow configuring pool with no replicas"),
+
     Option("mon_warn_on_misplaced", Option::TYPE_BOOL, Option::LEVEL_ADVANCED)
     .set_default(false)
     .add_service("mgr")
index b4cc322b9f0b5a350b544b3e33d161ac379a19fe..3316452b4b0b60ad71bc32641330f519246b5567 100644 (file)
@@ -7929,6 +7929,19 @@ int OSDMonitor::prepare_command_pool_set(const cmdmap_t& cmdmap,
       ss << "pool size must be between 1 and 10";
       return -EINVAL;
     }
+    if (n == 1) {
+      if (!g_conf().get_val<bool>("mon_allow_pool_size_one")) {
+       ss << "configuring pool size as 1 is disabled by default.";
+       return -EPERM;
+      }
+      bool sure = false;
+      cmd_getval(cmdmap, "yes_i_really_mean_it", sure);
+      if (!sure) { ss << "WARNING: setting pool size 1 could lead to data loss "
+       "without recovery. If you are *ABSOLUTELY CERTAIN* that is what you want, "
+         "pass the flag --yes-i-really-mean-it.";
+       return -EPERM;
+      }
+    }
     if (!osdmap.crush->check_crush_rule(p.get_crush_rule(), p.type, n, ss)) {
       return -EINVAL;
     }
index d8246b27327b6f3243ac7976dc5d3a9cae5f2f7d..ee04dd180045f59e9f35e15d6d42136bcd0e0df7 100755 (executable)
@@ -27,7 +27,7 @@ setup() {
        for pool in `./ceph osd pool ls`; do
            local size=`./ceph osd pool get ${pool} size | awk '{print $2}'`
            if [ "${size}" -gt "${CEPH_NUM_OSD}" ]; then
-               ./ceph osd pool set ${pool} size ${CEPH_NUM_OSD}
+               ./ceph osd pool set ${pool} size ${CEPH_NUM_OSD} --yes-i-really-mean-it
                changed=1
            fi
        done
index 2327e923a56b8bd08d54af6a8b0a0553acbd8b11..29d450c8718336f022cdf3abd26b2e4aea044932 100755 (executable)
@@ -1259,6 +1259,7 @@ mon_osd_reporter_subtree_level = osd
 mon_data_avail_warn = 2
 mon_data_avail_crit = 1
 mon_allow_pool_delete = true
+mon_allow_pool_size_one = true
 
 [osd]
 osd_scrub_load_threshold = 2000