mirror of
https://github.com/ceph/ceph
synced 2025-04-01 14:51:13 +00:00
rbd: ignore tx-only mirror peers when adding new peers
There is a restriction for supporting only a single RX peer but we should support multiple TX-only peers. Fixes: https://tracker.ceph.com/issues/44938 Signed-off-by: Jason Dillaman <dillaman@redhat.com>
This commit is contained in:
parent
a5ade11a31
commit
366ecdb26d
@ -1017,8 +1017,19 @@ int execute_peer_add(const po::variables_map &vm,
|
||||
std::cerr << "rbd: failed to list mirror peers" << std::endl;
|
||||
return r;
|
||||
}
|
||||
|
||||
// ignore tx-only peers since the restriction is for rx
|
||||
mirror_peers.erase(
|
||||
std::remove_if(
|
||||
mirror_peers.begin(), mirror_peers.end(),
|
||||
[](const librbd::mirror_peer_site_t& peer) {
|
||||
return (peer.direction == RBD_MIRROR_PEER_DIRECTION_TX);
|
||||
}),
|
||||
mirror_peers.end());
|
||||
|
||||
if (!mirror_peers.empty()) {
|
||||
std::cerr << "rbd: multiple peers are not currently supported" << std::endl;
|
||||
std::cerr << "rbd: multiple RX peers are not currently supported"
|
||||
<< std::endl;
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
@ -1173,8 +1184,37 @@ int execute_peer_set(const po::variables_map &vm,
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
r = rbd.mirror_peer_site_set_direction(
|
||||
io_ctx, uuid, boost::any_cast<rbd_mirror_peer_direction_t>(direction));
|
||||
auto peer_direction = boost::any_cast<rbd_mirror_peer_direction_t>(
|
||||
direction);
|
||||
if (peer_direction != RBD_MIRROR_PEER_DIRECTION_TX) {
|
||||
// TODO: temporary restriction to prevent adding multiple peers
|
||||
// until rbd-mirror daemon can properly handle the scenario
|
||||
std::vector<librbd::mirror_peer_site_t> mirror_peers;
|
||||
r = rbd.mirror_peer_site_list(io_ctx, &mirror_peers);
|
||||
if (r < 0) {
|
||||
std::cerr << "rbd: failed to list mirror peers" << std::endl;
|
||||
return r;
|
||||
}
|
||||
|
||||
// ignore peer to be updated and tx-only peers since the restriction is
|
||||
// for rx
|
||||
mirror_peers.erase(
|
||||
std::remove_if(
|
||||
mirror_peers.begin(), mirror_peers.end(),
|
||||
[uuid](const librbd::mirror_peer_site_t& peer) {
|
||||
return (peer.uuid == uuid ||
|
||||
peer.direction == RBD_MIRROR_PEER_DIRECTION_TX);
|
||||
}),
|
||||
mirror_peers.end());
|
||||
|
||||
if (!mirror_peers.empty()) {
|
||||
std::cerr << "rbd: multiple RX peers are not currently supported"
|
||||
<< std::endl;
|
||||
return -EINVAL;
|
||||
}
|
||||
}
|
||||
|
||||
r = rbd.mirror_peer_site_set_direction(io_ctx, uuid, peer_direction);
|
||||
} else {
|
||||
r = update_peer_config_key(io_ctx, uuid, key, value);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user