Skip to content

Commit 091c7c5

Browse files
authored
Merge pull request ceph#61289 from ronen-fr/wip-rf-catcher-fix
common: fix md_config_cacher_t Reviewed-by: Radoslaw Zarzynski <[email protected]>
2 parents f992060 + 5a966ca commit 091c7c5

File tree

4 files changed

+58
-50
lines changed

4 files changed

+58
-50
lines changed

qa/standalone/scrub/osd-recovery-scrub.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,7 @@ function wait_for_scrub_mod() {
163163
fi
164164
sleep 1
165165
# are we still the primary?
166-
local current_primary=`bin/ceph pg $pgid query | jq '.acting[0]' `
166+
local current_primary=`./bin/ceph pg $pgid query | jq '.acting[0]' `
167167
if [ $orig_primary != $current_primary ]; then
168168
echo $orig_primary no longer primary for $pgid
169169
return 0
@@ -194,7 +194,7 @@ function pg_scrub_mod() {
194194

195195
local last_scrub=$(get_last_scrub_stamp $pgid)
196196
# locate the primary
197-
local my_primary=`bin/ceph pg $pgid query | jq '.acting[0]' `
197+
local my_primary=`./bin/ceph pg $pgid query | jq '.acting[0]' `
198198
local recovery=false
199199
ceph pg scrub $pgid
200200
#ceph --format json pg dump pgs | jq ".pg_stats | .[] | select(.pgid == \"$pgid\") | .state"

qa/standalone/scrub/osd-scrub-test.sh

Lines changed: 39 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -603,17 +603,16 @@ function TEST_dump_scrub_schedule() {
603603
declare -A expct_dmp_duration=( ['dmp_last_duration']="0" ['dmp_last_duration_neg']="not0" )
604604
wait_any_cond $pgid 10 $saved_last_stamp expct_dmp_duration "WaitingAfterScrub_dmp " sched_data || return 1
605605

606-
sleep 2
607-
608606
#
609607
# step 2: set noscrub and request a "periodic scrub". Watch for the change in the 'is the scrub
610608
# scheduled for the future' value
611609
#
612610

613-
ceph tell osd.* config set osd_shallow_scrub_chunk_max "3" || return 1
614-
ceph tell osd.* config set osd_scrub_sleep "2.0" || return 1
615611
ceph osd set noscrub || return 1
616612
sleep 2
613+
ceph tell osd.* config set osd_shallow_scrub_chunk_max "3" || return 1
614+
ceph tell osd.* config set osd_scrub_sleep "2.0" || return 1
615+
sleep 8
617616
saved_last_stamp=${sched_data['query_last_stamp']}
618617

619618
ceph tell $pgid schedule-scrub
@@ -692,28 +691,28 @@ function wait_initial_scrubs() {
692691

693692
# set a long schedule for the periodic scrubs. Wait for the
694693
# initial 'no previous scrub is known' scrubs to finish for all PGs.
695-
bin/ceph tell osd.* config set osd_scrub_min_interval 7200
696-
bin/ceph tell osd.* config set osd_deep_scrub_interval 14400
697-
bin/ceph tell osd.* config set osd_max_scrubs 32
698-
bin/ceph tell osd.* config set osd_scrub_sleep 0
699-
bin/ceph tell osd.* config set osd_shallow_scrub_chunk_max 10
700-
bin/ceph tell osd.* config set osd_scrub_chunk_max 10
694+
ceph tell osd.* config set osd_scrub_min_interval 7200
695+
ceph tell osd.* config set osd_deep_scrub_interval 14400
696+
ceph tell osd.* config set osd_max_scrubs 32
697+
ceph tell osd.* config set osd_scrub_sleep 0
698+
ceph tell osd.* config set osd_shallow_scrub_chunk_max 10
699+
ceph tell osd.* config set osd_scrub_chunk_max 10
701700

702701
for pg in "${!pg_to_prim_dict[@]}"; do
703702
(( extr_dbg >= 1 )) && echo "Scheduling initial scrub for $pg"
704-
bin/ceph tell $pg scrub || return 1
703+
ceph tell $pg scrub || return 1
705704
done
706705

707706
sleep 1
708-
(( extr_dbg >= 1 )) && bin/ceph pg dump pgs --format=json-pretty | \
707+
(( extr_dbg >= 1 )) && ceph pg dump pgs --format=json-pretty | \
709708
jq '.pg_stats | map(select(.last_scrub_duration == 0)) | map({pgid: .pgid, last_scrub_duration: .last_scrub_duration})'
710709

711710
tout=20
712711
while [ $tout -gt 0 ] ; do
713712
sleep 0.5
714-
(( extr_dbg >= 2 )) && bin/ceph pg dump pgs --format=json-pretty | \
713+
(( extr_dbg >= 2 )) && ceph pg dump pgs --format=json-pretty | \
715714
jq '.pg_stats | map(select(.last_scrub_duration == 0)) | map({pgid: .pgid, last_scrub_duration: .last_scrub_duration})'
716-
not_done=$(bin/ceph pg dump pgs --format=json-pretty | \
715+
not_done=$(ceph pg dump pgs --format=json-pretty | \
717716
jq '.pg_stats | map(select(.last_scrub_duration == 0)) | map({pgid: .pgid, last_scrub_duration: .last_scrub_duration})' | wc -l )
718717
# note that we should ignore a header line
719718
if [ "$not_done" -le 1 ]; then
@@ -782,14 +781,14 @@ function TEST_abort_periodic_for_operator() {
782781
wait_initial_scrubs pg_pr || return 1
783782

784783
# limit all OSDs to one scrub at a time
785-
bin/ceph tell osd.* config set osd_max_scrubs 1
786-
bin/ceph tell osd.* config set osd_stats_update_period_not_scrubbing 1
784+
ceph tell osd.* config set osd_max_scrubs 1
785+
ceph tell osd.* config set osd_stats_update_period_not_scrubbing 1
787786

788787
# configure for slow scrubs
789-
bin/ceph tell osd.* config set osd_scrub_sleep 3
790-
bin/ceph tell osd.* config set osd_shallow_scrub_chunk_max 2
791-
bin/ceph tell osd.* config set osd_scrub_chunk_max 2
792-
(( extr_dbg >= 2 )) && bin/ceph tell osd.2 dump_scrub_reservations --format=json-pretty
788+
ceph tell osd.* config set osd_scrub_sleep 3
789+
ceph tell osd.* config set osd_shallow_scrub_chunk_max 2
790+
ceph tell osd.* config set osd_scrub_chunk_max 2
791+
(( extr_dbg >= 2 )) && ceph tell osd.2 dump_scrub_reservations --format=json-pretty
793792

794793
# the first PG to work with:
795794
local pg1="1.0"
@@ -812,7 +811,7 @@ function TEST_abort_periodic_for_operator() {
812811
fi
813812

814813
# the common primary is allowed two concurrent scrubs
815-
bin/ceph tell osd."${pg_pr[$pg1]}" config set osd_max_scrubs 2
814+
ceph tell osd."${pg_pr[$pg1]}" config set osd_max_scrubs 2
816815
echo "The two PGs to manipulate are $pg1 and $pg2"
817816

818817
set_query_debug "$pg1"
@@ -821,31 +820,31 @@ function TEST_abort_periodic_for_operator() {
821820
local is_act
822821
for i in $( seq 1 3 )
823822
do
824-
is_act=$(bin/ceph pg "$pg1" query | jq '.scrubber.active')
823+
is_act=$(ceph pg "$pg1" query | jq '.scrubber.active')
825824
if [[ "$is_act" = "false" ]]; then
826825
break
827826
fi
828827
echo "Still waiting for pg $pg1 to finish scrubbing"
829828
sleep 0.7
830829
done
831-
bin/ceph pg dump pgs
830+
ceph pg dump pgs
832831
if [[ "$is_act" != "false" ]]; then
833-
bin/ceph pg "$pg1" query
832+
ceph pg "$pg1" query
834833
echo "PG $pg1 appears to be still scrubbing"
835834
return 1
836835
fi
837836
sleep 0.5
838837

839838
echo "Initiating a periodic scrub of $pg1"
840-
(( extr_dbg >= 2 )) && bin/ceph pg "$pg1" query -f json-pretty | jq '.scrubber'
841-
bin/ceph tell $pg1 schedule-deep-scrub || return 1
839+
(( extr_dbg >= 2 )) && ceph pg "$pg1" query -f json-pretty | jq '.scrubber'
840+
ceph tell $pg1 schedule-deep-scrub || return 1
842841
sleep 1
843-
(( extr_dbg >= 2 )) && bin/ceph pg "$pg1" query -f json-pretty | jq '.scrubber'
842+
(( extr_dbg >= 2 )) && ceph pg "$pg1" query -f json-pretty | jq '.scrubber'
844843

845844
for i in $( seq 1 14 )
846845
do
847846
sleep 0.5
848-
stt=$(bin/ceph pg "$pg1" query | jq '.scrubber')
847+
stt=$(ceph pg "$pg1" query | jq '.scrubber')
849848
is_active=$(echo $stt | jq '.active')
850849
is_reserving_replicas=$(echo $stt | jq '.is_reserving_replicas')
851850
if [[ "$is_active" = "true" && "$is_reserving_replicas" = "false" ]]; then
@@ -854,49 +853,49 @@ function TEST_abort_periodic_for_operator() {
854853
echo "Still waiting for pg $pg1 to start scrubbing: $stt"
855854
done
856855
if [[ "$is_active" != "true" || "$is_reserving_replicas" != "false" ]]; then
857-
bin/ceph pg "$pg1" query -f json-pretty | jq '.scrubber'
856+
ceph pg "$pg1" query -f json-pretty | jq '.scrubber'
858857
echo "The scrub is not active or is reserving replicas"
859858
return 1
860859
fi
861-
(( extr_dbg >= 2 )) && bin/ceph pg "$pg1" query -f json-pretty | jq '.scrubber'
860+
(( extr_dbg >= 2 )) && ceph pg "$pg1" query -f json-pretty | jq '.scrubber'
862861

863862

864863
# PG 1 is scrubbing, and has reserved the replicas - soem of which are shared
865864
# by PG 2. As the max-scrubs was set to 1, that should prevent PG 2 from
866865
# reserving its replicas.
867866

868-
(( extr_dbg >= 1 )) && bin/ceph tell osd.* dump_scrub_reservations --format=json-pretty
867+
(( extr_dbg >= 1 )) && ceph tell osd.* dump_scrub_reservations --format=json-pretty
869868

870869
# now - the 2'nd scrub - which should be blocked on reserving
871870
set_query_debug "$pg2"
872-
bin/ceph tell "$pg2" schedule-deep-scrub
871+
ceph tell "$pg2" schedule-deep-scrub
873872
sleep 0.5
874873
(( extr_dbg >= 2 )) && echo "===================================================================================="
875-
(( extr_dbg >= 2 )) && bin/ceph pg "$pg2" query -f json-pretty | jq '.scrubber'
876-
(( extr_dbg >= 2 )) && bin/ceph pg "$pg1" query -f json-pretty | jq '.scrubber'
874+
(( extr_dbg >= 2 )) && ceph pg "$pg2" query -f json-pretty | jq '.scrubber'
875+
(( extr_dbg >= 2 )) && ceph pg "$pg1" query -f json-pretty | jq '.scrubber'
877876
sleep 1
878877
(( extr_dbg >= 2 )) && echo "===================================================================================="
879-
(( extr_dbg >= 2 )) && bin/ceph pg "$pg2" query -f json-pretty | jq '.scrubber'
880-
(( extr_dbg >= 2 )) && bin/ceph pg "$pg1" query -f json-pretty | jq '.scrubber'
878+
(( extr_dbg >= 2 )) && ceph pg "$pg2" query -f json-pretty | jq '.scrubber'
879+
(( extr_dbg >= 2 )) && ceph pg "$pg1" query -f json-pretty | jq '.scrubber'
881880

882881
# make sure pg2 scrub is stuck in the reserving state
883-
local stt2=$(bin/ceph pg "$pg2" query | jq '.scrubber')
882+
local stt2=$(ceph pg "$pg2" query | jq '.scrubber')
884883
local pg2_is_reserving
885884
pg2_is_reserving=$(echo $stt2 | jq '.is_reserving_replicas')
886885
if [[ "$pg2_is_reserving" != "true" ]]; then
887886
echo "The scheduled scrub for $pg2 should have been stuck"
888-
bin/ceph pg dump pgs
887+
ceph pg dump pgs
889888
return 1
890889
fi
891890

892891
# now - issue an operator-initiated scrub on pg2.
893892
# The periodic scrub should be aborted, and the operator-initiated scrub should start.
894893
echo "Instructing $pg2 to perform a high-priority scrub"
895-
bin/ceph tell "$pg2" scrub
894+
ceph tell "$pg2" scrub
896895
for i in $( seq 1 10 )
897896
do
898897
sleep 0.5
899-
stt2=$(bin/ceph pg "$pg2" query | jq '.scrubber')
898+
stt2=$(ceph pg "$pg2" query | jq '.scrubber')
900899
pg2_is_active=$(echo $stt2 | jq '.active')
901900
pg2_is_reserving=$(echo $stt2 | jq '.is_reserving_replicas')
902901
if [[ "$pg2_is_active" = "true" && "$pg2_is_reserving" != "true" ]]; then

qa/standalone/scrub/scrub-helpers.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -320,7 +320,7 @@ function build_pg_dicts {
320320

321321
# if the infile name is '-', fetch the dump directly from the ceph cluster
322322
if [[ $infile == "-" ]]; then
323-
local -r ceph_cmd="bin/ceph pg dump pgs_brief -f=json-pretty"
323+
local -r ceph_cmd="ceph pg dump pgs_brief -f=json-pretty"
324324
local -r ceph_cmd_out=$(eval $ceph_cmd)
325325
local -r ceph_cmd_rc=$?
326326
if [[ $ceph_cmd_rc -ne 0 ]]; then

src/common/config_cacher.h

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -18,32 +18,41 @@
1818
#include "common/config_obs.h"
1919
#include "common/config.h"
2020

21+
/**
22+
* A simple class to cache a single configuration value.
23+
* Points to note:
24+
* - as get_tracked_conf_keys() must return a pointer to a null-terminated
25+
* array of C-strings, 'keys' - an array - is used to hold the sole key
26+
* that this observer is interested in.
27+
* - the const cast should be removed once we change the
28+
* get_tracked_conf_keys() to return const char* const * (or something
29+
* similar).
30+
*/
2131
template <typename ValueT>
2232
class md_config_cacher_t : public md_config_obs_t {
2333
ConfigProxy& conf;
24-
const char* const option_name;
34+
const char* keys[2];
2535
std::atomic<ValueT> value_cache;
2636

2737
const char** get_tracked_conf_keys() const override {
28-
const static char* keys[] = { option_name, nullptr };
29-
return keys;
38+
return const_cast<const char**>(keys);
3039
}
3140

3241
void handle_conf_change(const ConfigProxy& conf,
3342
const std::set<std::string>& changed) override {
34-
if (changed.count(option_name)) {
35-
value_cache.store(conf.get_val<ValueT>(option_name));
43+
if (changed.contains(keys[0])) {
44+
value_cache.store(conf.get_val<ValueT>(keys[0]));
3645
}
3746
}
3847

3948
public:
4049
md_config_cacher_t(ConfigProxy& conf,
4150
const char* const option_name)
4251
: conf(conf),
43-
option_name(option_name) {
52+
keys{option_name, nullptr} {
4453
conf.add_observer(this);
4554
std::atomic_init(&value_cache,
46-
conf.get_val<ValueT>(option_name));
55+
conf.get_val<ValueT>(keys[0]));
4756
}
4857

4958
~md_config_cacher_t() {

0 commit comments

Comments
 (0)