From d3cc647583bfd3fb61a0cb7b5040085aaa138750 Mon Sep 17 00:00:00 2001 From: David Zafman Date: Tue, 3 Nov 2020 03:26:57 +0000 Subject: [PATCH] osd: Eliminate day of weeek 7 and hour 24 Add test case for permitted hours to make sure scrub doesn't start Remove permitted hours in extended sleep test Fixes: https://tracker.ceph.com/issues/48077 Signed-off-by: David Zafman --- PendingReleaseNotes | 8 ++++ doc/rados/configuration/osd-config-ref.rst | 42 +++++++++++------ qa/standalone/scrub/osd-scrub-test.sh | 53 ++++++++++++++++++++-- src/common/options.cc | 14 ++++-- 4 files changed, 96 insertions(+), 21 deletions(-) diff --git a/PendingReleaseNotes b/PendingReleaseNotes index 32e8b0addbd7c..13e3e818927c7 100644 --- a/PendingReleaseNotes +++ b/PendingReleaseNotes @@ -15,6 +15,14 @@ Please refer to https://docs.ceph.com/en/latest/ceph-volume/lvm/batch/ for more detailed information. +* Configuration variables for permitted scrub times have changed. The legal + values for ``osd_scrub_begin_hour`` and ``osd_scrub_end_hour`` are 0 - 23. + The use of 24 is now illegal. Specifying ``0`` for both values causes every + hour to be allowed. The legal vaues for ``osd_scrub_begin_week_day`` and + ``osd_scrub_end_week_day`` are 0 - 6. The use of 7 is now illegal. + Specifying ``0`` for both values causes every day of the week to be allowed. + + >=15.0.0 -------- diff --git a/doc/rados/configuration/osd-config-ref.rst b/doc/rados/configuration/osd-config-ref.rst index c3e65f6092429..b0705f3e74354 100644 --- a/doc/rados/configuration/osd-config-ref.rst +++ b/doc/rados/configuration/osd-config-ref.rst @@ -218,37 +218,53 @@ scrubbing operations. ``osd scrub begin hour`` -:Description: The time of day for the lower bound when a scheduled scrub can be - performed. -:Type: Integer in the range of 0 to 24 +:Description: This restricts scrubbing to this hour of the day or later. + Use ``osd scrub begin hour = 0`` and ``osd scrub end hour = 0`` + to allow scrubbing the entire day. Along with ``osd scrub end hour``, they define a time + window, in which the scrubs can happen. + But a scrub will be performed + no matter whether the time window allows or not, as long as the placement + group's scrub interval exceeds ``osd scrub max interval``. +:Type: Integer in the range of 0 to 23 :Default: ``0`` ``osd scrub end hour`` -:Description: The time of day for the upper bound when a scheduled scrub can be - performed. Along with ``osd scrub begin hour``, they define a time +:Description: This restricts scrubbing to the hour earlier than this. + Use ``osd scrub begin hour = 0`` and ``osd scrub end hour = 0`` to allow scrubbing + for the entire day. Along with ``osd scrub begin hour``, they define a time window, in which the scrubs can happen. But a scrub will be performed - no matter the time window allows or not, as long as the placement + no matter whether the time window allows or not, as long as the placement group's scrub interval exceeds ``osd scrub max interval``. -:Type: Integer in the range of 0 to 24 -:Default: ``24`` +:Type: Integer in the range of 0 to 23 +:Default: ``0`` ``osd scrub begin week day`` :Description: This restricts scrubbing to this day of the week or later. - 0 or 7 = Sunday, 1 = Monday, etc. -:Type: Integer in the range of 0 to 7 + 0 = Sunday, 1 = Monday, etc. Use ``osd scrub begin week day = 0`` + and ``osd scrub end week day = 0`` to allow scrubbing for the entire week. + Along with ``osd scrub end week day``, they define a time window, in which + the scrubs can happen. But a scrub will be performed + no matter whether the time window allows or not, as long as the placement + group's scrub interval exceeds ``osd scrub max interval``. +:Type: Integer in the range of 0 to 6 :Default: ``0`` ``osd scrub end week day`` :Description: This restricts scrubbing to days of the week earlier than this. - 0 or 7 = Sunday, 1 = Monday, etc. -:Type: Integer in the range of 0 to 7 -:Default: ``7`` + 0 = Sunday, 1 = Monday, etc. Use ``osd scrub begin week day = 0`` + and ``osd scrub end week day = 0`` to allow scrubbing for the entire week. + Along with ``osd scrub begin week day``, they define a time + window, in which the scrubs can happen. But a scrub will be performed + no matter whether the time window allows or not, as long as the placement + group's scrub interval exceeds ``osd scrub max interval``. +:Type: Integer in the range of 0 to 6 +:Default: ``0`` ``osd scrub during recovery`` diff --git a/qa/standalone/scrub/osd-scrub-test.sh b/qa/standalone/scrub/osd-scrub-test.sh index 89534938063e0..3e1cd0d984b0b 100755 --- a/qa/standalone/scrub/osd-scrub-test.sh +++ b/qa/standalone/scrub/osd-scrub-test.sh @@ -198,15 +198,13 @@ function TEST_scrub_extented_sleep() { setup $dir || return 1 run_mon $dir a --osd_pool_default_size=3 || return 1 run_mgr $dir x || return 1 - local scrub_begin_hour=$(date -d '2 hour ago' +"%H" | sed 's/^0//') - local scrub_end_hour=$(date -d '1 hour ago' +"%H" | sed 's/^0//') for osd in $(seq 0 $(expr $OSDS - 1)) do run_osd $dir $osd --osd_scrub_sleep=0 \ --osd_scrub_extended_sleep=10 \ --bluestore_cache_autotune=false \ - --osd_scrub_begin_hour=$scrub_begin_hour \ - --osd_scrub_end_hour=$scrub_end_hour || return 1 + --osd_deep_scrub_randomize_ratio=0.0 \ + --osd_scrub_interval_randomize_ratio=0 || return 1 done # Create a pool with a single pg @@ -344,6 +342,53 @@ function TEST_deep_scrub_abort() { _scrub_abort $dir deep_scrub } +function TEST_scrub_permit_time() { + local dir=$1 + local poolname=test + local OSDS=3 + local objects=15 + + TESTDATA="testdata.$$" + + setup $dir || return 1 + run_mon $dir a --osd_pool_default_size=3 || return 1 + run_mgr $dir x || return 1 + local scrub_begin_hour=$(date -d '2 hour ago' +"%H" | sed 's/^0//') + local scrub_end_hour=$(date -d '1 hour ago' +"%H" | sed 's/^0//') + for osd in $(seq 0 $(expr $OSDS - 1)) + do + run_osd $dir $osd --bluestore_cache_autotune=false \ + --osd_deep_scrub_randomize_ratio=0.0 \ + --osd_scrub_interval_randomize_ratio=0 \ + --osd_scrub_begin_hour=$scrub_begin_hour \ + --osd_scrub_end_hour=$scrub_end_hour || return 1 + done + + # Create a pool with a single pg + create_pool $poolname 1 1 + wait_for_clean || return 1 + + # Trigger a scrub on a PG + local pgid=$(get_pg $poolname SOMETHING) + local primary=$(get_primary $poolname SOMETHING) + local last_scrub=$(get_last_scrub_stamp $pgid) + # If we don't specify an amount of time to subtract from + # current time to set last_scrub_stamp, it sets the deadline + # back by osd_max_interval which would cause the time permit checking + # to be skipped. Set back 1 day, the default scrub_min_interval. + ceph tell $pgid scrub $(( 24 * 60 * 60 )) || return 1 + + # Scrub should not run + for ((i=0; i < 30; i++)); do + if test "$(get_last_scrub_stamp $pgid)" '>' "$last_scrub" ; then + return 1 + fi + sleep 1 + done + + teardown $dir || return 1 +} + main osd-scrub-test "$@" # Local Variables: diff --git a/src/common/options.cc b/src/common/options.cc index 34bee688353f9..f8c3ea1bec3cc 100644 --- a/src/common/options.cc +++ b/src/common/options.cc @@ -3257,24 +3257,30 @@ std::vector