From 0a76d6cd01db1370ff457fd1d143f379df3fbd6c Mon Sep 17 00:00:00 2001 From: Ronen Friedman Date: Thu, 20 Feb 2025 10:15:44 -0600 Subject: [PATCH] qa/standalone/scrub: retry in TEST_abort_periodic_for_operator() The scenario created in the test requires two PGs that share the same Primary, and at least one more member of their active sets. The PR handles the (unlikely) case where the first PG tried does not have a counterpart that matches the requirements. A minor related fix in scrub-helpers.sh: using 'printf' to return a value, instead of an out (ref) parameter. Fixes: https://tracker.ceph.com/issues/69837 Signed-off-by: Ronen Friedman --- qa/standalone/scrub/osd-scrub-test.sh | 26 ++++++++++++++------------ qa/standalone/scrub/scrub-helpers.sh | 6 ++---- 2 files changed, 16 insertions(+), 16 deletions(-) diff --git a/qa/standalone/scrub/osd-scrub-test.sh b/qa/standalone/scrub/osd-scrub-test.sh index 3e4664d3138..33b246d6067 100755 --- a/qa/standalone/scrub/osd-scrub-test.sh +++ b/qa/standalone/scrub/osd-scrub-test.sh @@ -790,23 +790,25 @@ function TEST_abort_periodic_for_operator() { (( extr_dbg >= 2 )) && ceph tell osd.2 dump_scrub_reservations --format=json-pretty # the first PG to work with: - local pg1="1.0" - # and another one, that shares its primary, and at least one more active set member local pg2="" - for pg in "${!pg_pr[@]}"; do - if [[ "${pg_pr[$pg]}" == "${pg_pr[$pg1]}" ]]; then - local -i common=0 - count_common_active $pg $pg1 pg_ac common - if [[ $common -gt 1 ]]; then - pg2=$pg - break + for pg1 in "${!pg_pr[@]}"; do + for pg in "${!pg_pr[@]}"; do + if [[ "$pg" == "$pg1" ]]; then + continue fi - fi + if [[ "${pg_pr[$pg]}" == "${pg_pr[$pg1]}" ]]; then + local -i common=$(count_common_active $pg $pg1 pg_ac) + if [[ $common -gt 1 ]]; then + pg2=$pg + break 2 + fi + fi + done done + if [[ -z "$pg2" ]]; then - # \todo handle the case when no such PG is found echo "No PG found with the same primary as $pg1" - return 1 + return 0 # not an error fi # the common primary is allowed two concurrent scrubs diff --git a/qa/standalone/scrub/scrub-helpers.sh b/qa/standalone/scrub/scrub-helpers.sh index dd37b643e08..bb09a00a7fe 100644 --- a/qa/standalone/scrub/scrub-helpers.sh +++ b/qa/standalone/scrub/scrub-helpers.sh @@ -358,7 +358,6 @@ function count_common_active { local pg1=$1 local pg2=$2 local -n pg_acting_dict=$3 - local -n res=$4 local -a a1=(${pg_acting_dict[$pg1]}) local -a a2=(${pg_acting_dict[$pg2]}) @@ -372,7 +371,7 @@ function count_common_active { done done - res=$cnt + printf '%d' "$cnt" } @@ -389,8 +388,7 @@ function find_disjoint_but_primary { for cand in "${!ac_dict[@]}"; do if [[ "$cand" != "$pg" ]]; then - local -i common=0 - count_common_active "$pg" "$cand" ac_dict common + local -i common=$(count_common_active "$pg" "$cand" ac_dict) if [[ $common -eq 0 || ( $common -eq 1 && "${p_dict[$pg]}" == "${p_dict[$cand]}" )]]; then res=$cand return -- 2.39.5