Skip to content

Commit e14afbc

Browse files
rbd-mirror: prevent image deletion if remote image is not primary
A resync on a mirrored image may incorrectly results in the local image being deleted even when the remote image is no longer primary. This issue can occur under the following conditions: * if resync is requested on the secondary before the remote image has been fully demoted * if the demotion of the primary image is not mirrored due to the rbd-mirror daemon being offline. This can be fixed by ensuring that image deletion during a resync is only allowed when the remote image is confirmed to be primary. This commit fixes the issue only for snapshot based mirroring mode Fixes: https://tracker.ceph.com/issues/70948 Signed-off-by: VinayBhaskar-V <[email protected]>
1 parent e1f7b2c commit e14afbc

File tree

5 files changed

+308
-135
lines changed

5 files changed

+308
-135
lines changed

qa/workunits/rbd/rbd_mirror.sh

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -526,6 +526,54 @@ for i in ${image2} ${image4}; do
526526
remove_image_retry ${CLUSTER2} ${POOL} ${i}
527527
done
528528

529+
if [ "${RBD_MIRROR_MODE}" = "snapshot" ]; then
530+
testlog "TEST: request image resync when remote is not primary"
531+
test_resync_image=test_resync_image
532+
create_image_and_enable_mirror ${CLUSTER2} ${POOL} ${test_resync_image} ${RBD_MIRROR_MODE}
533+
write_image ${CLUSTER2} ${POOL} ${test_resync_image} 100
534+
wait_for_image_replay_stopped ${CLUSTER2} ${POOL} ${test_resync_image}
535+
wait_for_image_replay_started ${CLUSTER1} ${POOL} ${test_resync_image}
536+
wait_for_replay_complete ${CLUSTER1} ${CLUSTER2} ${POOL} ${POOL} ${test_resync_image}
537+
wait_for_replaying_status_in_pool_dir ${CLUSTER1} ${POOL} ${test_resync_image}
538+
wait_for_status_in_pool_dir ${CLUSTER2} ${POOL} ${test_resync_image} 'up+stopped'
539+
write_image ${CLUSTER2} ${POOL} ${test_resync_image} 100
540+
demote_image ${CLUSTER2} ${POOL} ${test_resync_image}
541+
request_resync_image ${CLUSTER1} ${POOL} ${test_resync_image} test_resync_image_id
542+
wait_for_status_in_pool_dir ${CLUSTER2} ${POOL} ${test_resync_image} 'up+unknown' 'remote image is not primary'
543+
wait_for_status_in_pool_dir ${CLUSTER1} ${POOL} ${test_resync_image} 'up+unknown' 'remote image is not primary'
544+
promote_image ${CLUSTER1} ${POOL} ${test_resync_image}
545+
wait_for_image_replay_started ${CLUSTER2} ${POOL} ${test_resync_image}
546+
wait_for_status_in_pool_dir ${CLUSTER1} ${POOL} ${test_resync_image} 'up+stopped'
547+
wait_for_status_in_pool_dir ${CLUSTER2} ${POOL} ${test_resync_image} 'up+replaying'
548+
compare_images ${CLUSTER1} ${CLUSTER2} ${POOL} ${POOL} ${test_resync_image}
549+
remove_image_retry ${CLUSTER1} ${POOL} ${test_resync_image}
550+
551+
if [ -z "${RBD_MIRROR_USE_RBD_MIRROR}" ]; then
552+
testlog "TEST: request image resync when remote is not primary and daemon is offline"
553+
test_resync_image=test_resync_image
554+
create_image_and_enable_mirror ${CLUSTER2} ${POOL} ${test_resync_image} ${RBD_MIRROR_MODE}
555+
write_image ${CLUSTER2} ${POOL} ${test_resync_image} 100
556+
wait_for_image_replay_stopped ${CLUSTER2} ${POOL} ${test_resync_image}
557+
wait_for_image_replay_started ${CLUSTER1} ${POOL} ${test_resync_image}
558+
wait_for_replay_complete ${CLUSTER1} ${CLUSTER2} ${POOL} ${POOL} ${test_resync_image}
559+
wait_for_replaying_status_in_pool_dir ${CLUSTER1} ${POOL} ${test_resync_image}
560+
wait_for_status_in_pool_dir ${CLUSTER2} ${POOL} ${test_resync_image} 'up+stopped'
561+
stop_mirrors ${CLUSTER1}
562+
write_image ${CLUSTER2} ${POOL} ${test_resync_image} 100
563+
demote_image ${CLUSTER2} ${POOL} ${test_resync_image}
564+
request_resync_image ${CLUSTER1} ${POOL} ${test_resync_image} test_resync_image_id
565+
start_mirrors ${CLUSTER1}
566+
wait_for_status_in_pool_dir ${CLUSTER2} ${POOL} ${test_resync_image} 'up+unknown' 'remote image is not primary'
567+
wait_for_status_in_pool_dir ${CLUSTER1} ${POOL} ${test_resync_image} 'up+unknown' 'remote image is not primary'
568+
promote_image ${CLUSTER1} ${POOL} ${test_resync_image}
569+
wait_for_image_replay_started ${CLUSTER2} ${POOL} ${test_resync_image}
570+
wait_for_status_in_pool_dir ${CLUSTER1} ${POOL} ${test_resync_image} 'up+stopped'
571+
wait_for_status_in_pool_dir ${CLUSTER2} ${POOL} ${test_resync_image} 'up+replaying'
572+
compare_images ${CLUSTER1} ${CLUSTER2} ${POOL} ${POOL} ${test_resync_image}
573+
remove_image_retry ${CLUSTER1} ${POOL} ${test_resync_image}
574+
fi
575+
fi
576+
529577
testlog "TEST: disable mirror while daemon is stopped"
530578
stop_mirrors ${CLUSTER1}
531579
stop_mirrors ${CLUSTER2}

0 commit comments

Comments
 (0)