mirror of
https://github.com/ceph/ceph
synced 2024-12-30 07:23:11 +00:00
Merge PR #26794 into master
* refs/pull/26794/head: mon/MgrMonitor: only try to update always_on_modules if >= NAUTILUS qa/standalone/mon/msgr-v2-transition: add some tests for enabling msgr v2 mon/MonmapMonitor: add 'ceph mon set-addrs <name> <addrvec>' command Revert "mon/MonClient: disable ms_bind_msgr2 if NAUTILUS feature not set" mon/OSDMonitor: use legacy_equals to compare osd addrs msg/msg_types: make legacy_equals() symmetrical mon/MDSMonitor: stop using get_orig_source_inst() Reviewed-by: Patrick Donnelly <pdonnell@redhat.com> Reviewed-by: Neha Ojha <nojha@redhat.com>
This commit is contained in:
commit
62136d381a
82
qa/standalone/mon/msgr-v2-transition.sh
Executable file
82
qa/standalone/mon/msgr-v2-transition.sh
Executable file
@ -0,0 +1,82 @@
|
||||
#!/usr/bin/env bash
|
||||
#
|
||||
|
||||
source $CEPH_ROOT/qa/standalone/ceph-helpers.sh
|
||||
|
||||
function run() {
|
||||
local dir=$1
|
||||
shift
|
||||
|
||||
export CEPH_MON_V1="v1:127.0.0.1:7148" # git grep '\<7148\>' : there must be only one
|
||||
export CEPH_MON_V2="v2:127.0.0.1:7149" # git grep '\<7149\>' : there must be only one
|
||||
export CEPH_ARGS
|
||||
CEPH_ARGS+="--fsid=$(uuidgen) --auth-supported=none "
|
||||
|
||||
local funcs=${@:-$(set | ${SED} -n -e 's/^\(TEST_[0-9a-z_]*\) .*/\1/p')}
|
||||
for func in $funcs ; do
|
||||
setup $dir || return 1
|
||||
$func $dir || return 1
|
||||
teardown $dir || return 1
|
||||
done
|
||||
}
|
||||
|
||||
function TEST_mon_v1_osd_addrs() {
|
||||
local dir=$1
|
||||
|
||||
export CEPH_ARGS="$CEPH_ARGS --mon-host=$CEPH_MON_V1 --mon-debug-no-require-nautilus"
|
||||
run_mon $dir a || return 1
|
||||
|
||||
ceph mon dump | grep mon.a | grep $CEPH_MON_V1
|
||||
|
||||
run_osd $dir 0 || return 1
|
||||
wait_for_osd up 0 || return 1
|
||||
ceph osd dump | grep osd.0 | grep v1: || return 1
|
||||
ceph osd dump | grep osd.0 | grep v2: && return 1
|
||||
|
||||
ceph osd require-osd-release nautilus
|
||||
|
||||
ceph osd down 0
|
||||
wait_for_osd up 0 || return 1
|
||||
|
||||
# public should be v1, cluster v2
|
||||
ceph osd dump | grep osd.0 | grep v1: || return 1
|
||||
ceph osd dump -f json | jq '.osds[0].public_addrs.addrvec[0]' | grep v1 || return 1
|
||||
ceph osd dump -f json | jq '.osds[0].cluster_addrs.addrvec[0]' | grep v2 || return 1
|
||||
|
||||
# enable v2 port on mon
|
||||
ceph mon set-addrs a "[$CEPH_MON_V2,$CEPH_MON_V1]"
|
||||
|
||||
ceph osd down 0
|
||||
wait_for_osd up 0 || return 1
|
||||
|
||||
# both public and cluster should be v2+v1
|
||||
ceph osd dump | grep osd.0 | grep v1: || return 1
|
||||
ceph osd dump -f json | jq '.osds[0].public_addrs.addrvec[0]' | grep v2 || return 1
|
||||
ceph osd dump -f json | jq '.osds[0].cluster_addrs.addrvec[0]' | grep v2 || return 1
|
||||
}
|
||||
|
||||
function TEST_mon_v2v1_osd_addrs() {
|
||||
local dir=$1
|
||||
|
||||
export CEPH_ARGS="$CEPH_ARGS --mon-host=[$CEPH_MON_V2,$CEPH_MON_V1] --mon-debug-no-require-nautilus"
|
||||
run_mon $dir a || return 1
|
||||
|
||||
ceph mon dump | grep mon.a | grep $CEPH_MON_V1
|
||||
|
||||
run_osd $dir 0 || return 1
|
||||
wait_for_osd up 0 || return 1
|
||||
ceph osd dump | grep osd.0 | grep v1: || return 1
|
||||
ceph osd dump | grep osd.0 | grep v2: && return 1
|
||||
|
||||
ceph osd require-osd-release nautilus
|
||||
|
||||
ceph osd down 0
|
||||
wait_for_osd up 0 || return 1
|
||||
|
||||
# both public and cluster should be v2+v1
|
||||
ceph osd dump | grep osd.0 | grep v1: || return 1
|
||||
ceph osd dump -f json | jq '.osds[0].public_addrs.addrvec[0]' | grep v2 || return 1
|
||||
ceph osd dump -f json | jq '.osds[0].cluster_addrs.addrvec[0]' | grep v2 || return 1
|
||||
}
|
||||
|
||||
main msgr-v2-transition "$@"
|
@ -278,7 +278,8 @@ bool MDSMonitor::preprocess_query(MonOpRequestRef op)
|
||||
{
|
||||
op->mark_mdsmon_event(__func__);
|
||||
PaxosServiceMessage *m = static_cast<PaxosServiceMessage*>(op->get_req());
|
||||
dout(10) << "preprocess_query " << *m << " from " << m->get_orig_source_inst() << dendl;
|
||||
dout(10) << "preprocess_query " << *m << " from " << m->get_orig_source()
|
||||
<< " " << m->get_orig_source_addrs() << dendl;
|
||||
|
||||
switch (m->get_type()) {
|
||||
|
||||
@ -342,7 +343,8 @@ bool MDSMonitor::preprocess_beacon(MonOpRequestRef op)
|
||||
}
|
||||
|
||||
dout(5) << "preprocess_beacon " << *m
|
||||
<< " from " << m->get_orig_source_inst()
|
||||
<< " from " << m->get_orig_source()
|
||||
<< " " << m->get_orig_source_addrs()
|
||||
<< " " << m->get_compat()
|
||||
<< dendl;
|
||||
|
||||
@ -354,7 +356,9 @@ bool MDSMonitor::preprocess_beacon(MonOpRequestRef op)
|
||||
|
||||
// check compat
|
||||
if (!m->get_compat().writeable(fsmap.compat)) {
|
||||
dout(1) << " mds " << m->get_source_inst() << " can't write to fsmap " << fsmap.compat << dendl;
|
||||
dout(1) << " mds " << m->get_orig_source()
|
||||
<< " " << m->get_orig_source_addrs()
|
||||
<< " can't write to fsmap " << fsmap.compat << dendl;
|
||||
goto ignore;
|
||||
}
|
||||
|
||||
@ -529,7 +533,8 @@ bool MDSMonitor::prepare_beacon(MonOpRequestRef op)
|
||||
op->mark_mdsmon_event(__func__);
|
||||
MMDSBeacon *m = static_cast<MMDSBeacon*>(op->get_req());
|
||||
// -- this is an update --
|
||||
dout(12) << "prepare_beacon " << *m << " from " << m->get_orig_source_inst() << dendl;
|
||||
dout(12) << "prepare_beacon " << *m << " from " << m->get_orig_source()
|
||||
<< " " << m->get_orig_source_addrs() << dendl;
|
||||
entity_addrvec_t addrs = m->get_orig_source_addrs();
|
||||
mds_gid_t gid = m->get_global_id();
|
||||
MDSMap::DaemonState state = m->get_state();
|
||||
@ -557,7 +562,7 @@ bool MDSMonitor::prepare_beacon(MonOpRequestRef op)
|
||||
|
||||
for (const auto &new_metric: new_health) {
|
||||
if (old_types.count(new_metric.type) == 0) {
|
||||
dout(10) << "MDS health message (" << m->get_orig_source_inst().name
|
||||
dout(10) << "MDS health message (" << m->get_orig_source()
|
||||
<< "): " << new_metric.sev << " " << new_metric.message << dendl;
|
||||
}
|
||||
}
|
||||
@ -566,7 +571,7 @@ bool MDSMonitor::prepare_beacon(MonOpRequestRef op)
|
||||
for (const auto &old_metric : old_health) {
|
||||
if (new_types.count(old_metric.type) == 0) {
|
||||
mon->clog->info() << "MDS health message cleared ("
|
||||
<< m->get_orig_source_inst().name << "): " << old_metric.message;
|
||||
<< m->get_orig_source() << "): " << old_metric.message;
|
||||
}
|
||||
}
|
||||
|
||||
@ -814,8 +819,9 @@ void MDSMonitor::_updated(MonOpRequestRef op)
|
||||
op->mark_mdsmon_event(__func__);
|
||||
MMDSBeacon *m = static_cast<MMDSBeacon*>(op->get_req());
|
||||
dout(10) << "_updated " << m->get_orig_source() << " " << *m << dendl;
|
||||
mon->clog->debug() << m->get_orig_source_inst() << " "
|
||||
<< ceph_mds_state_name(m->get_state());
|
||||
mon->clog->debug() << m->get_orig_source() << " "
|
||||
<< m->get_orig_source_addrs() << " "
|
||||
<< ceph_mds_state_name(m->get_state());
|
||||
|
||||
if (m->get_state() == MDSMap::STATE_STOPPED) {
|
||||
// send the map manually (they're out of the map, so they won't get it automatic)
|
||||
|
@ -651,10 +651,12 @@ void MgrMonitor::on_active()
|
||||
if (mon->is_leader()) {
|
||||
mon->clog->debug() << "mgrmap e" << map.epoch << ": " << map;
|
||||
|
||||
if (pending_map.always_on_modules != always_on_modules) {
|
||||
if (HAVE_FEATURE(mon->get_quorum_con_features(), SERVER_NAUTILUS) &&
|
||||
pending_map.always_on_modules != always_on_modules) {
|
||||
pending_map.always_on_modules = always_on_modules;
|
||||
dout(4) << "always on modules changed "
|
||||
<< pending_map.get_always_on_modules() << dendl;
|
||||
dout(4) << "always on modules changed, pending "
|
||||
<< pending_map.get_always_on_modules()
|
||||
<< " != wanted " << always_on_modules << dendl;
|
||||
propose_pending();
|
||||
}
|
||||
}
|
||||
|
@ -380,15 +380,6 @@ void MonClient::handle_monmap(MMonMap *m)
|
||||
monmap.print(*_dout);
|
||||
*_dout << dendl;
|
||||
|
||||
if (monmap.get_epoch() > 0 &&
|
||||
!monmap.get_required_features().contains_all(
|
||||
ceph::features::mon::FEATURE_NAUTILUS) &&
|
||||
cct->_conf.get_val<bool>("ms_bind_msgr2")) {
|
||||
ldout(cct,1) << " disabling ms_bind_msgr2 because monmap does not have"
|
||||
<< " NAUTILUS feature set" << dendl;
|
||||
cct->_conf.set_val("ms_bind_msgr2", "false");
|
||||
}
|
||||
|
||||
if (old_name.size() == 0) {
|
||||
ldout(cct,10) << " can't identify which mon we were connected to" << dendl;
|
||||
_reopen_session();
|
||||
|
@ -458,6 +458,11 @@ COMMAND("mon set-rank " \
|
||||
"name=rank,type=CephInt",
|
||||
"set the rank for the specified mon",
|
||||
"mon", "rw")
|
||||
COMMAND("mon set-addrs " \
|
||||
"name=name,type=CephString " \
|
||||
"name=addrs,type=CephString",
|
||||
"set the addrs (IPs and ports) a specific monitor binds to",
|
||||
"mon", "rw")
|
||||
COMMAND("mon enable-msgr2",
|
||||
"enable the msgr2 protocol on port 3300",
|
||||
"mon", "rw")
|
||||
|
@ -751,6 +751,37 @@ bool MonmapMonitor::prepare_command(MonOpRequestRef op)
|
||||
pending_map.set_rank(name, rank);
|
||||
pending_map.last_changed = ceph_clock_now();
|
||||
propose = true;
|
||||
} else if (prefix == "mon set-addrs") {
|
||||
string name;
|
||||
string addrs;
|
||||
if (!cmd_getval(g_ceph_context, cmdmap, "name", name) ||
|
||||
!cmd_getval(g_ceph_context, cmdmap, "addrs", addrs)) {
|
||||
err = -EINVAL;
|
||||
goto reply;
|
||||
}
|
||||
if (!pending_map.contains(name)) {
|
||||
ss << "mon." << name << " does not exist";
|
||||
err = -ENOENT;
|
||||
goto reply;
|
||||
}
|
||||
entity_addrvec_t av;
|
||||
if (!av.parse(addrs.c_str(), nullptr)) {
|
||||
ss << "failed to parse addrs '" << addrs << "'";
|
||||
err = -EINVAL;
|
||||
goto reply;
|
||||
}
|
||||
for (auto& a : av.v) {
|
||||
a.set_nonce(0);
|
||||
if (!a.get_port()) {
|
||||
ss << "monitor must bind to a non-zero port, not " << a;
|
||||
err = -EINVAL;
|
||||
goto reply;
|
||||
}
|
||||
}
|
||||
err = 0;
|
||||
pending_map.set_addrvec(name, av);
|
||||
pending_map.last_changed = ceph_clock_now();
|
||||
propose = true;
|
||||
} else if (prefix == "mon enable-msgr2") {
|
||||
if (!monmap.get_required_features().contains_all(
|
||||
ceph::features::mon::FEATURE_NAUTILUS)) {
|
||||
|
@ -2299,7 +2299,7 @@ bool OSDMonitor::preprocess_failure(MonOpRequestRef op)
|
||||
if (m->get_orig_source().is_osd()) {
|
||||
int from = m->get_orig_source().num();
|
||||
if (!osdmap.exists(from) ||
|
||||
osdmap.get_addrs(from) != m->get_orig_source_addrs() ||
|
||||
!osdmap.get_addrs(from).legacy_equals(m->get_orig_source_addrs()) ||
|
||||
(osdmap.is_down(from) && m->if_osd_failed())) {
|
||||
dout(5) << "preprocess_failure from dead osd." << from
|
||||
<< ", ignoring" << dendl;
|
||||
@ -2844,12 +2844,12 @@ bool OSDMonitor::preprocess_boot(MonOpRequestRef op)
|
||||
|
||||
// already booted?
|
||||
if (osdmap.is_up(from) &&
|
||||
osdmap.get_addrs(from) == m->get_orig_source_addrs() &&
|
||||
osdmap.get_cluster_addrs(from) == m->cluster_addrs) {
|
||||
osdmap.get_addrs(from).legacy_equals(m->get_orig_source_addrs()) &&
|
||||
osdmap.get_cluster_addrs(from).legacy_equals(m->cluster_addrs)) {
|
||||
// yup.
|
||||
dout(7) << "preprocess_boot dup from " << m->get_orig_source()
|
||||
<< " " << m->get_orig_source_addrs()
|
||||
<< " == " << osdmap.get_addrs(from) << dendl;
|
||||
<< " =~ " << osdmap.get_addrs(from) << dendl;
|
||||
_booted(op, false);
|
||||
return true;
|
||||
}
|
||||
@ -2866,7 +2866,8 @@ bool OSDMonitor::preprocess_boot(MonOpRequestRef op)
|
||||
|
||||
if (osdmap.exists(from) &&
|
||||
osdmap.get_info(from).up_from > m->version &&
|
||||
osdmap.get_most_recent_addrs(from) == m->get_orig_source_addrs()) {
|
||||
osdmap.get_most_recent_addrs(from).legacy_equals(
|
||||
m->get_orig_source_addrs())) {
|
||||
dout(7) << "prepare_boot msg from before last up_from, ignoring" << dendl;
|
||||
send_latest(op, m->sb.current_epoch+1);
|
||||
return true;
|
||||
@ -2917,8 +2918,9 @@ bool OSDMonitor::prepare_boot(MonOpRequestRef op)
|
||||
dout(7) << __func__ << " was up, first marking down osd." << from << " "
|
||||
<< osdmap.get_addrs(from) << dendl;
|
||||
// preprocess should have caught these; if not, assert.
|
||||
ceph_assert(osdmap.get_addrs(from) != m->get_orig_source_addrs() ||
|
||||
osdmap.get_cluster_addrs(from) != m->cluster_addrs);
|
||||
ceph_assert(!osdmap.get_addrs(from).legacy_equals(
|
||||
m->get_orig_source_addrs()) ||
|
||||
!osdmap.get_cluster_addrs(from).legacy_equals(m->cluster_addrs));
|
||||
ceph_assert(osdmap.get_uuid(from) == m->sb.osd_fsid);
|
||||
|
||||
if (pending_inc.new_state.count(from) == 0 ||
|
||||
@ -3084,9 +3086,10 @@ bool OSDMonitor::preprocess_full(MonOpRequestRef op)
|
||||
goto ignore;
|
||||
}
|
||||
if ((!osdmap.is_up(from) &&
|
||||
osdmap.get_most_recent_addrs(from) == m->get_orig_source_addrs()) ||
|
||||
osdmap.get_most_recent_addrs(from).legacy_equals(
|
||||
m->get_orig_source_addrs())) ||
|
||||
(osdmap.is_up(from) &&
|
||||
osdmap.get_addrs(from) != m->get_orig_source_addrs())) {
|
||||
!osdmap.get_addrs(from).legacy_equals(m->get_orig_source_addrs()))) {
|
||||
dout(7) << __func__ << " ignoring full message from down "
|
||||
<< m->get_orig_source_inst() << dendl;
|
||||
goto ignore;
|
||||
@ -3167,7 +3170,7 @@ bool OSDMonitor::preprocess_alive(MonOpRequestRef op)
|
||||
}
|
||||
|
||||
if (!osdmap.is_up(from) ||
|
||||
osdmap.get_addrs(from) != m->get_orig_source_addrs()) {
|
||||
!osdmap.get_addrs(from).legacy_equals(m->get_orig_source_addrs())) {
|
||||
dout(7) << "preprocess_alive ignoring alive message from down "
|
||||
<< m->get_orig_source() << " " << m->get_orig_source_addrs()
|
||||
<< dendl;
|
||||
@ -3246,7 +3249,8 @@ bool OSDMonitor::prepare_pg_created(MonOpRequestRef op)
|
||||
auto from = src.num();
|
||||
if (!src.is_osd() ||
|
||||
!mon->osdmon()->osdmap.is_up(from) ||
|
||||
m->get_orig_source_addrs() != mon->osdmon()->osdmap.get_addrs(from)) {
|
||||
!mon->osdmon()->osdmap.get_addrs(from).legacy_equals(
|
||||
m->get_orig_source_addrs())) {
|
||||
dout(1) << __func__ << " ignoring stats from non-active osd." << dendl;
|
||||
return false;
|
||||
}
|
||||
@ -3370,7 +3374,7 @@ bool OSDMonitor::preprocess_pgtemp(MonOpRequestRef op)
|
||||
}
|
||||
|
||||
if (!osdmap.is_up(from) ||
|
||||
osdmap.get_addrs(from) != m->get_orig_source_addrs()) {
|
||||
!osdmap.get_addrs(from).legacy_equals(m->get_orig_source_addrs())) {
|
||||
dout(7) << "ignoring pgtemp message from down "
|
||||
<< m->get_orig_source() << " " << m->get_orig_source_addrs()
|
||||
<< dendl;
|
||||
@ -3612,7 +3616,7 @@ bool OSDMonitor::prepare_beacon(MonOpRequestRef op)
|
||||
|
||||
if (!src.is_osd() ||
|
||||
!osdmap.is_up(from) ||
|
||||
beacon->get_orig_source_addrs() != osdmap.get_addrs(from)) {
|
||||
!osdmap.get_addrs(from).legacy_equals(beacon->get_orig_source_addrs())) {
|
||||
if (src.is_osd() && !osdmap.is_up(from)) {
|
||||
// share some new maps with this guy in case it may not be
|
||||
// aware of its own deadness...
|
||||
|
@ -669,6 +669,11 @@ struct entity_addrvec_t {
|
||||
front() == o.legacy_addr()) {
|
||||
return true;
|
||||
}
|
||||
if (o.v.size() == 1 &&
|
||||
o.front().is_legacy() &&
|
||||
o.front() == legacy_addr()) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -300,3 +300,33 @@ TEST(entity_addrvec_t, parse)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
TEST(entity_addrvec_t, legacy_equals)
|
||||
{
|
||||
entity_addr_t a1, a2;
|
||||
ASSERT_TRUE(a1.parse("v1:1.2.3.4:567/890"));
|
||||
ASSERT_TRUE(a2.parse("v2:1.2.3.4:567/890"));
|
||||
entity_addrvec_t av1(a1);
|
||||
entity_addrvec_t av21;
|
||||
av21.v.push_back(a2);
|
||||
av21.v.push_back(a1);
|
||||
ASSERT_TRUE(av1.legacy_equals(av1));
|
||||
ASSERT_TRUE(av21.legacy_equals(av21));
|
||||
ASSERT_TRUE(av1.legacy_equals(av21));
|
||||
ASSERT_TRUE(av21.legacy_equals(av1));
|
||||
|
||||
entity_addr_t b1, b2;
|
||||
ASSERT_TRUE(b1.parse("v1:1.2.3.5:567/8"));
|
||||
ASSERT_TRUE(b2.parse("v2:1.2.3.5:567/8"));
|
||||
entity_addrvec_t bv1(b1);
|
||||
entity_addrvec_t bv21;
|
||||
bv21.v.push_back(b2);
|
||||
bv21.v.push_back(b1);
|
||||
ASSERT_TRUE(bv1.legacy_equals(bv21));
|
||||
ASSERT_TRUE(bv21.legacy_equals(bv1));
|
||||
|
||||
ASSERT_FALSE(av1.legacy_equals(bv1));
|
||||
ASSERT_FALSE(av21.legacy_equals(bv21));
|
||||
ASSERT_FALSE(av21.legacy_equals(bv1));
|
||||
ASSERT_FALSE(av1.legacy_equals(bv21));
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user