Skip to content

Commit 56f4acd

Browse files
committed
collect rbd mirror status in provider mode
this commit discards the collection of mirror status when mirroring is disabled on namespace Signed-off-by: yati1998 <[email protected]>
1 parent 1cba698 commit 56f4acd

File tree

1 file changed

+41
-31
lines changed

1 file changed

+41
-31
lines changed

collection-scripts/gather_ceph_resources

+41-31
Original file line numberDiff line numberDiff line change
@@ -367,12 +367,12 @@ for ns in $namespaces; do
367367
{
368368
printf "Collecting mirror pool status for: %s\n" "${bp}"
369369
timeout 120 oc -n "${ns}" exec "${HOSTNAME}"-helper -- bash -c "rbd mirror pool status --verbose $bp --format=json --pretty-format" 2>>"${COMMAND_ERR_OUTPUT_DIR}"/gather-rbd-mirror-pool-status-"${bp}"-debug.log
370-
} >>"${COMMAND_OUTPUT_DIR}"/rbd_mirror_pool_status &
370+
} >>"${COMMAND_OUTPUT_DIR}"/rbd_mirror_pool_status_"${bp}" &
371371
pids_rbd+=($!)
372372
{
373373
printf "Collecting mirror pool info for: %s\n" "${bp}"
374374
timeout 120 oc -n "${ns}" exec "${HOSTNAME}"-helper -- bash -c "rbd mirror pool info $bp --format=json --pretty-format" 2>>"${COMMAND_ERR_OUTPUT_DIR}"/gather-rbd-mirror-pool-info-"${bp}"-debug.log
375-
} >>"${COMMAND_OUTPUT_DIR}"/rbd_mirror_pool_info &
375+
} >>"${COMMAND_OUTPUT_DIR}"/rbd_mirror_pool_info_"${bp}" &
376376
pids_rbd+=($!)
377377
images=$(timeout 60 oc -n "${ns}" exec "${HOSTNAME}"-helper -- bash -c "rbd ls -p $bp")
378378
for image in $images; do
@@ -388,42 +388,52 @@ for ns in $namespaces; do
388388
dbglog "waiting for ${pids_rbd[*]} to terminate"
389389
wait "${pids_rbd[@]}"
390390
fi
391-
find "${COMMAND_OUTPUT_DIR}" -name "rbd_mirror_image_status_*.part" -print0 | xargs -0 cat >>"${COMMAND_OUTPUT_DIR}"/rbd_mirror_image_status
391+
find "${COMMAND_OUTPUT_DIR}" -name "rbd_mirror_image_status_*.part" -print0 | xargs -0 cat >>"${COMMAND_OUTPUT_DIR}"/rbd_mirror_image_status_"${bp}"
392392
find "${COMMAND_OUTPUT_DIR}" -name "rbd_mirror_image_status_*.part" -print0 | xargs -0 rm -f
393393
# Collecting mirror image status for provider mode with rados namespace
394-
rados_namespaces=$(timeout 60 oc -n "${ns}" exec "${HOSTNAME}"-helper -- bash -c "rbd -p $bp namespace ls")
395-
for rns in $rados_namespaces; do
396-
{
397-
printf "Collecting mirror pool status in: %s/%s\n" "${bp}" "${rns}"
398-
timeout 120 oc -n "${ns}" exec "${HOSTNAME}"-helper -- bash -c "rbd mirror pool status --verbose $bp --namespace ${rns} --format=json --pretty-format" 2>>"${COMMAND_ERR_OUTPUT_DIR}"/gather-rbd-mirror-pool-status-"${bp}"-debug.log
399-
} >>"${COMMAND_OUTPUT_DIR}"/rbd_mirror_pool_status_"${bp}"_"${rns}" &
400-
pids_rbd+=($!)
401-
{
402-
printf "Collecting mirror pool info in: %s/%s\n" "${bp}" "${rns}"
403-
timeout 120 oc -n "${ns}" exec "${HOSTNAME}"-helper -- bash -c "rbd mirror pool info $bp --namespace ${rns} --format=json --pretty-format" 2>>"${COMMAND_ERR_OUTPUT_DIR}"/gather-rbd-mirror-pool-info-"${bp}"-debug.log
404-
} >>"${COMMAND_OUTPUT_DIR}"/rbd_mirror_pool_info_"${bp}"_"${rns}" &
405-
pids_rbd+=($!)
406-
images=$(timeout 60 oc -n "${ns}" exec "${HOSTNAME}"-helper -- bash -c "rbd ls -p $bp --namespace ${rns}")
407-
for image in $images; do
408-
dbglogf "${CEPH_GATHER_DBGLOG}" "Printing information for image: ${image}"
394+
rados_namespaces=$(timeout 60 oc -n "${ns}" exec "${HOSTNAME}"-helper -- bash -c "rbd -p $bp namespace ls")
395+
# skip the header from above output
396+
namespaces="${rados_namespaces[@]:5}"
397+
for rns in $namespaces; do
398+
isEnabled=$(timeout 60 oc -n "${ns}" exec "${HOSTNAME}"-helper -- bash -c "rbd mirror pool info $bp --namespace ${rns} --format=json | jq --raw-output '.mode'")
399+
if [ "${isEnabled}" != "disabled" ]; then
400+
dbglogf "${CEPH_GATHER_DBGLOG}" "Mirroring is enabled on: ${bp} ${rns}"
409401
{
410-
printf "Collecting mirror image status for images in: %s/%s/%s\n" "${bp}" "${rns}" "${image}"
411-
timeout 120 oc -n "${ns}" exec "${HOSTNAME}"-helper -- bash -c "rbd mirror image status $bp/$image --namespace ${rns} --format=json --pretty-format" 2>>"${COMMAND_ERR_OUTPUT_DIR}"/gather-rbd-mirror-image-status-"${bp}"-"${image}"-debug.log
412-
} >>"${COMMAND_OUTPUT_DIR}"/rbd_mirror_image_status_"${image}"_"${rns}".part &
402+
printf "Collecting mirror pool status in: %s/%s\n" "${bp}" "${rns}"
403+
timeout 120 oc -n "${ns}" exec "${HOSTNAME}"-helper -- bash -c "rbd mirror pool status --verbose $bp --namespace ${rns} --format=json --pretty-format" 2>>"${COMMAND_ERR_OUTPUT_DIR}"/gather-rbd-mirror-pool-status-"${bp}"-"${rns}"-debug.log
404+
} >>"${COMMAND_OUTPUT_DIR}"/rbd_mirror_pool_status_"${bp}"_"${rns}" &
413405
pids_rbd+=($!)
414-
done
415-
if [ -n "${pids_rbd[*]}" ]; then
416-
# wait for all pids
417-
dbglog "waiting for ${pids_rbd[*]} to terminate"
418-
wait "${pids_rbd[@]}"
406+
{
407+
printf "Collecting mirror pool info in: %s/%s\n" "${bp}" "${rns}"
408+
timeout 120 oc -n "${ns}" exec "${HOSTNAME}"-helper -- bash -c "rbd mirror pool info $bp --namespace ${rns} --format=json --pretty-format" 2>>"${COMMAND_ERR_OUTPUT_DIR}"/gather-rbd-mirror-pool-info-"${bp}"-"${rns}"-debug.log
409+
} >>"${COMMAND_OUTPUT_DIR}"/rbd_mirror_pool_info_"${bp}"_"${rns}" &
410+
pids_rbd+=($!)
411+
images=$(timeout 60 oc -n "${ns}" exec "${HOSTNAME}"-helper -- bash -c "rbd ls -p $bp --namespace ${rns}")
412+
for image in $images; do
413+
dbglogf "${CEPH_GATHER_DBGLOG}" "Printing information for image: ${image}"
414+
{
415+
printf "Collecting mirror image status for: %s/%s/%s\n" "${bp}" "${rns}" "${image}"
416+
timeout 120 oc -n "${ns}" exec "${HOSTNAME}"-helper -- bash -c "rbd mirror image status $bp/$image --namespace ${rns} --format=json --pretty-format" 2>>"${COMMAND_ERR_OUTPUT_DIR}"/gather-rbd-mirror-image-status-"${bp}"-"${rns}"-"${image}"-debug.log
417+
} >>"${COMMAND_OUTPUT_DIR}"/rbd_mirror_image_status_"${image}"_"${rns}".part &
418+
pids_rbd+=($!)
419+
done
420+
if [ -n "${pids_rbd[*]}" ]; then
421+
# wait for all pids
422+
dbglog "waiting for ${pids_rbd[*]} to terminate"
423+
wait "${pids_rbd[@]}"
424+
fi
425+
find "${COMMAND_OUTPUT_DIR}" -name "rbd_mirror_image_status_*.part" -print0 | xargs -0 cat >>"${COMMAND_OUTPUT_DIR}"/rbd_mirror_image_status_"${bp}"_"${rns}"
426+
find "${COMMAND_OUTPUT_DIR}" -name "rbd_mirror_image_status_*.part" -print0 | xargs -0 rm -f
427+
else
428+
printf "Mirroring is disabled on: %s %s\n" "${bp}" "${rns}" >>"${COMMAND_OUTPUT_DIR}"/rbd_mirror_pool_status_"${bp}"_"${rns}"
429+
printf "Mirroring is disabled on: %s %s\n" "${bp}" "${rns}" >>"${COMMAND_OUTPUT_DIR}"/rbd_mirror_pool_info_"${bp}"_"${rns}"
430+
printf "Mirroring is disabled on: %s %s\n" "${bp}" "${rns}" >>"${COMMAND_OUTPUT_DIR}"/rbd_mirror_image_status_"${bp}"_"${rns}"
419431
fi
420-
find "${COMMAND_OUTPUT_DIR}" -name "rbd_mirror_image_status_*.part" -print0 | xargs -0 cat >>"${COMMAND_OUTPUT_DIR}"/rbd_mirror_image_status_"${bp}"_"${rns}"
421-
find "${COMMAND_OUTPUT_DIR}" -name "rbd_mirror_image_status_*.part" -print0 | xargs -0 rm -f
422432
done
423433
else
424-
printf "Mirroring is disabled on: %s\n" "${bp}" >>"${COMMAND_OUTPUT_DIR}"/rbd_mirror_pool_status
425-
printf "Mirroring is disabled on: %s\n" "${bp}" >>"${COMMAND_OUTPUT_DIR}"/rbd_mirror_pool_info
426-
printf "Mirroring is disabled on: %s\n" "${bp}" >>"${COMMAND_OUTPUT_DIR}"/rbd_mirror_image_status
434+
printf "Mirroring is disabled on: %s\n" "${bp}" >>"${COMMAND_OUTPUT_DIR}"/rbd_mirror_pool_status_"${bp}"
435+
printf "Mirroring is disabled on: %s\n" "${bp}" >>"${COMMAND_OUTPUT_DIR}"/rbd_mirror_pool_info_"${bp}"
436+
printf "Mirroring is disabled on: %s\n" "${bp}" >>"${COMMAND_OUTPUT_DIR}"/rbd_mirror_image_status_"${bp}"
427437
fi
428438
done
429439

0 commit comments

Comments
 (0)