Skip to content

Commit ea3a567

Browse files
committed
qa/workunits: make wait_for_status_in_pool_dir() reentrant
In rbd_mirror_helpers.sh, the `wait_for_status_in_pool_dir()` helper stored `mirror image status` and `mirror pool status` command outputs in files that could be shared over successive calls or calls from multiple threads. Instead store the command outputs in local variables to make `wait_for_status_in_pool_dir()` reentrant. Signed-off-by: Ramana Raja <[email protected]>
1 parent 8cd25c3 commit ea3a567

File tree

1 file changed

+15
-16
lines changed

1 file changed

+15
-16
lines changed

qa/workunits/rbd/rbd_mirror_helpers.sh

Lines changed: 15 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -823,23 +823,23 @@ test_status_in_pool_dir()
823823
local description_pattern="$5"
824824
local service_pattern="$6"
825825

826-
local status_log=${TEMPDIR}/$(mkfname ${cluster}-${pool}-${image}.mirror_status)
827-
CEPH_ARGS='' rbd --cluster ${cluster} mirror image status ${pool}/${image} |
828-
tee ${status_log} >&2
829-
grep "^ state: .*${state_pattern}" ${status_log} || return 1
830-
grep "^ description: .*${description_pattern}" ${status_log} || return 1
826+
local status
827+
status=$(CEPH_ARGS='' rbd --cluster ${cluster} mirror image status \
828+
${pool}/${image})
829+
grep "^ state: .*${state_pattern}" <<< "$status" || return 1
830+
grep "^ description: .*${description_pattern}" <<< "$status" || return 1
831831

832832
if [ -n "${service_pattern}" ]; then
833-
grep "service: *${service_pattern}" ${status_log} || return 1
833+
grep "service: *${service_pattern}" <<< "$status" || return 1
834834
elif echo ${state_pattern} | grep '^up+'; then
835-
grep "service: *${MIRROR_USER_ID_PREFIX}.* on " ${status_log} || return 1
835+
grep "service: *${MIRROR_USER_ID_PREFIX}.* on " <<< "$status" || return 1
836836
else
837-
grep "service: " ${status_log} && return 1
837+
grep "service: " <<< "$status" && return 1
838838
fi
839839

840840
# recheck using `mirror pool status` command to stress test it.
841-
842-
local last_update="$(sed -nEe 's/^ last_update: *(.*) *$/\1/p' ${status_log})"
841+
local last_update
842+
last_update="$(sed -nEe 's/^ last_update: *(.*) *$/\1/p' <<< "$status")"
843843
test_mirror_pool_status_verbose \
844844
${cluster} ${pool} ${image} "${state_pattern}" "${last_update}" &&
845845
return 0
@@ -856,16 +856,15 @@ test_mirror_pool_status_verbose()
856856
local state_pattern="$4"
857857
local prev_last_update="$5"
858858

859-
local status_log=${TEMPDIR}/$(mkfname ${cluster}-${pool}.mirror_status)
860-
861-
rbd --cluster ${cluster} mirror pool status ${pool} --verbose --format xml \
862-
> ${status_log}
859+
local status
860+
status=$(CEPH_ARGS='' rbd --cluster ${cluster} mirror pool status ${pool} \
861+
--verbose --format xml)
863862

864863
local last_update state
865864
last_update=$($XMLSTARLET sel -t -v \
866-
"//images/image[name='${image}']/last_update" < ${status_log})
865+
"//images/image[name='${image}']/last_update" <<< "$status")
867866
state=$($XMLSTARLET sel -t -v \
868-
"//images/image[name='${image}']/state" < ${status_log})
867+
"//images/image[name='${image}']/state" <<< "$status")
869868

870869
echo "${state}" | grep "${state_pattern}" ||
871870
test "${last_update}" '>' "${prev_last_update}"

0 commit comments

Comments
 (0)