Skip to content

Commit e24bb7e

Browse files
authored
Merge pull request ceph#61768 from idryomov/wip-69911
librbd: fix mirror image status summary in a namespace Reviewed-by: N Balachandran <[email protected]>
2 parents a6f01f4 + 44804a3 commit e24bb7e

File tree

5 files changed

+48
-15
lines changed

5 files changed

+48
-15
lines changed

qa/workunits/rbd/rbd_mirror_bootstrap.sh

Lines changed: 40 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -35,22 +35,37 @@ done
3535
rbd --cluster ${CLUSTER1} --pool ${POOL} mirror pool info --format json | jq -e '.peers[0].direction == "tx-only"'
3636

3737
create_image_and_enable_mirror ${CLUSTER1} ${POOL} image1
38+
create_image_and_enable_mirror ${CLUSTER1} ${POOL}/${NS1} image1
3839

3940
wait_for_image_replay_started ${CLUSTER2} ${POOL} image1
4041
write_image ${CLUSTER1} ${POOL} image1 100
4142
wait_for_replay_complete ${CLUSTER2} ${CLUSTER1} ${POOL} ${POOL} image1
4243
wait_for_replaying_status_in_pool_dir ${CLUSTER2} ${POOL} image1
4344

45+
POOL_STATUS=$(get_pool_status_json ${CLUSTER1} ${POOL})
46+
jq -e '.summary.states == {"replaying": 1}' <<< ${POOL_STATUS}
47+
POOL_STATUS=$(get_pool_status_json ${CLUSTER2} ${POOL})
48+
jq -e '.summary.states == {"replaying": 1}' <<< ${POOL_STATUS}
49+
50+
wait_for_image_replay_started ${CLUSTER2} ${POOL}/${NS1} image1
51+
write_image ${CLUSTER1} ${POOL}/${NS1} image1 100
52+
wait_for_replay_complete ${CLUSTER2} ${CLUSTER1} ${POOL}/${NS1} ${POOL}/${NS1} image1
53+
wait_for_replaying_status_in_pool_dir ${CLUSTER2} ${POOL}/${NS1} image1
54+
55+
POOL_STATUS=$(get_pool_status_json ${CLUSTER1} ${POOL}/${NS1})
56+
jq -e '.summary.states == {"replaying": 1}' <<< ${POOL_STATUS}
57+
POOL_STATUS=$(get_pool_status_json ${CLUSTER2} ${POOL}/${NS1})
58+
jq -e '.summary.states == {"replaying": 1}' <<< ${POOL_STATUS}
59+
4460
testlog "TEST: verify rx-tx direction"
4561
# both rx-tx peers are added immediately by "rbd mirror pool peer bootstrap import"
4662
rbd --cluster ${CLUSTER1} --pool ${PARENT_POOL} mirror pool info --format json | jq -e '.peers[0].direction == "rx-tx"'
4763
rbd --cluster ${CLUSTER2} --pool ${PARENT_POOL} mirror pool info --format json | jq -e '.peers[0].direction == "rx-tx"'
4864

49-
create_image ${CLUSTER1} ${PARENT_POOL} image1
50-
create_image ${CLUSTER2} ${PARENT_POOL} image2
51-
52-
enable_mirror ${CLUSTER1} ${PARENT_POOL} image1
53-
enable_mirror ${CLUSTER2} ${PARENT_POOL} image2
65+
create_image_and_enable_mirror ${CLUSTER1} ${PARENT_POOL} image1
66+
create_image_and_enable_mirror ${CLUSTER2} ${PARENT_POOL} image2
67+
create_image_and_enable_mirror ${CLUSTER1} ${PARENT_POOL}/${NS1} image1
68+
create_image_and_enable_mirror ${CLUSTER2} ${PARENT_POOL}/${NS1} image2
5469

5570
wait_for_image_replay_started ${CLUSTER2} ${PARENT_POOL} image1
5671
write_image ${CLUSTER1} ${PARENT_POOL} image1 100
@@ -62,6 +77,26 @@ write_image ${CLUSTER2} ${PARENT_POOL} image2 100
6277
wait_for_replay_complete ${CLUSTER1} ${CLUSTER2} ${PARENT_POOL} ${PARENT_POOL} image2
6378
wait_for_replaying_status_in_pool_dir ${CLUSTER1} ${PARENT_POOL} image2
6479

80+
POOL_STATUS=$(get_pool_status_json ${CLUSTER1} ${PARENT_POOL})
81+
jq -e '.summary.states == {"replaying": 2}' <<< ${POOL_STATUS}
82+
POOL_STATUS=$(get_pool_status_json ${CLUSTER2} ${PARENT_POOL})
83+
jq -e '.summary.states == {"replaying": 2}' <<< ${POOL_STATUS}
84+
85+
wait_for_image_replay_started ${CLUSTER2} ${PARENT_POOL}/${NS1} image1
86+
write_image ${CLUSTER1} ${PARENT_POOL}/${NS1} image1 100
87+
wait_for_replay_complete ${CLUSTER2} ${CLUSTER1} ${PARENT_POOL}/${NS1} ${PARENT_POOL}/${NS1} image1
88+
wait_for_replaying_status_in_pool_dir ${CLUSTER2} ${PARENT_POOL}/${NS1} image1
89+
90+
wait_for_image_replay_started ${CLUSTER1} ${PARENT_POOL}/${NS1} image2
91+
write_image ${CLUSTER2} ${PARENT_POOL}/${NS1} image2 100
92+
wait_for_replay_complete ${CLUSTER1} ${CLUSTER2} ${PARENT_POOL}/${NS1} ${PARENT_POOL}/${NS1} image2
93+
wait_for_replaying_status_in_pool_dir ${CLUSTER1} ${PARENT_POOL}/${NS1} image2
94+
95+
POOL_STATUS=$(get_pool_status_json ${CLUSTER1} ${PARENT_POOL}/${NS1})
96+
jq -e '.summary.states == {"replaying": 2}' <<< ${POOL_STATUS}
97+
POOL_STATUS=$(get_pool_status_json ${CLUSTER2} ${PARENT_POOL}/${NS1})
98+
jq -e '.summary.states == {"replaying": 2}' <<< ${POOL_STATUS}
99+
65100
testlog "TEST: pool replayer and callout cleanup when peer is updated"
66101
test_health_state ${CLUSTER1} ${PARENT_POOL} 'OK'
67102
test_health_state ${CLUSTER2} ${PARENT_POOL} 'OK'

qa/workunits/rbd/rbd_mirror_helpers.sh

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -299,9 +299,11 @@ setup_pools()
299299

300300
rbd --cluster ${cluster} namespace create ${POOL}/${NS1}
301301
rbd --cluster ${cluster} namespace create ${POOL}/${NS2}
302+
rbd --cluster ${cluster} namespace create ${PARENT_POOL}/${NS1}
302303

303304
rbd --cluster ${cluster} mirror pool enable ${POOL}/${NS1} ${MIRROR_POOL_MODE}
304305
rbd --cluster ${cluster} mirror pool enable ${POOL}/${NS2} image
306+
rbd --cluster ${cluster} mirror pool enable ${PARENT_POOL}/${NS1} ${MIRROR_POOL_MODE}
305307

306308
if [ -z ${RBD_MIRROR_MANUAL_PEERS} ]; then
307309
if [ -z ${RBD_MIRROR_CONFIG_KEY} ]; then

src/librbd/api/Mirror.cc

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1993,8 +1993,11 @@ int Mirror<I>::image_status_summary(librados::IoCtx& io_ctx,
19931993
MirrorImageStatusStates *states) {
19941994
CephContext *cct = reinterpret_cast<CephContext *>(io_ctx.cct());
19951995

1996+
librados::IoCtx default_ns_io_ctx;
1997+
default_ns_io_ctx.dup(io_ctx);
1998+
default_ns_io_ctx.set_namespace("");
19961999
std::vector<cls::rbd::MirrorPeer> mirror_peers;
1997-
int r = cls_client::mirror_peer_list(&io_ctx, &mirror_peers);
2000+
int r = cls_client::mirror_peer_list(&default_ns_io_ctx, &mirror_peers);
19982001
if (r < 0 && r != -ENOENT) {
19992002
lderr(cct) << "failed to list mirror peers: " << cpp_strerror(r) << dendl;
20002003
return r;

src/tools/rbd/action/MirrorImage.cc

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -314,12 +314,8 @@ int execute_status(const po::variables_map &vm,
314314
return r;
315315
}
316316

317-
librados::IoCtx default_ns_io_ctx;
318-
default_ns_io_ctx.dup(io_ctx);
319-
default_ns_io_ctx.set_namespace("");
320-
321317
std::vector<librbd::mirror_peer_site_t> mirror_peers;
322-
utils::get_mirror_peer_sites(default_ns_io_ctx, &mirror_peers);
318+
utils::get_mirror_peer_sites(io_ctx, &mirror_peers);
323319

324320
std::map<std::string, std::string> peer_mirror_uuids_to_name;
325321
utils::get_mirror_peer_mirror_uuids_to_names(mirror_peers,

src/tools/rbd/action/MirrorPool.cc

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1646,11 +1646,8 @@ int execute_status(const po::variables_map &vm,
16461646
}
16471647

16481648
// dump per-image status
1649-
librados::IoCtx default_ns_io_ctx;
1650-
default_ns_io_ctx.dup(io_ctx);
1651-
default_ns_io_ctx.set_namespace("");
16521649
std::vector<librbd::mirror_peer_site_t> mirror_peers;
1653-
utils::get_mirror_peer_sites(default_ns_io_ctx, &mirror_peers);
1650+
utils::get_mirror_peer_sites(io_ctx, &mirror_peers);
16541651

16551652
std::map<std::string, std::string> peer_mirror_uuids_to_name;
16561653
utils::get_mirror_peer_mirror_uuids_to_names(mirror_peers,

0 commit comments

Comments
 (0)