| 408 | } |
| 409 | |
| 410 | bool MDSMonitor::preprocess_beacon(MonOpRequestRef op) |
| 411 | { |
| 412 | op->mark_mdsmon_event(__func__); |
| 413 | auto m = op->get_req<MMDSBeacon>(); |
| 414 | MDSMap::DaemonState state = m->get_state(); |
| 415 | mds_gid_t gid = m->get_global_id(); |
| 416 | version_t seq = m->get_seq(); |
| 417 | MDSMap::mds_info_t info; |
| 418 | epoch_t effective_epoch = 0; |
| 419 | |
| 420 | const auto &fsmap = get_fsmap(); |
| 421 | |
| 422 | // check privileges, ignore if fails |
| 423 | MonSession *session = op->get_session(); |
| 424 | if (!session) |
| 425 | goto ignore; |
| 426 | if (!session->is_capable("mds", MON_CAP_X)) { |
| 427 | dout(0) << "preprocess_beacon got MMDSBeacon from entity with insufficient privileges " |
| 428 | << session->caps << dendl; |
| 429 | goto ignore; |
| 430 | } |
| 431 | |
| 432 | if (m->get_fsid() != mon.monmap->fsid) { |
| 433 | dout(0) << "preprocess_beacon on fsid " << m->get_fsid() << " != " << mon.monmap->fsid << dendl; |
| 434 | goto ignore; |
| 435 | } |
| 436 | |
| 437 | dout(5) << "preprocess_beacon " << *m |
| 438 | << " from " << m->get_orig_source() |
| 439 | << " " << m->get_orig_source_addrs() |
| 440 | << " " << m->get_compat() |
| 441 | << dendl; |
| 442 | |
| 443 | // make sure the address has a port |
| 444 | if (m->get_orig_source_addr().get_port() == 0) { |
| 445 | dout(1) << " ignoring boot message without a port" << dendl; |
| 446 | goto ignore; |
| 447 | } |
| 448 | |
| 449 | // fw to leader? |
| 450 | if (!is_leader()) |
| 451 | return false; |
| 452 | |
| 453 | // booted, but not in map? |
| 454 | if (!fsmap.gid_exists(gid)) { |
| 455 | if (state != MDSMap::STATE_BOOT) { |
| 456 | dout(7) << "mds_beacon " << *m << " is not in fsmap (state " |
| 457 | << ceph_mds_state_name(state) << ")" << dendl; |
| 458 | |
| 459 | /* We can't send an MDSMap this MDS was a part of because we no longer |
| 460 | * know which FS it was part of. Nor does this matter. Sending an empty |
| 461 | * MDSMap is sufficient for getting the MDS to respawn. |
| 462 | */ |
| 463 | auto m = make_message<MMDSMap>(mon.monmap->fsid, MDSMap::create_null_mdsmap()); |
| 464 | mon.send_reply(op, m.detach()); |
| 465 | return true; |
| 466 | } else { |
| 467 | /* check if we've already recorded its entry in pending */ |
nothing calls this directly
no test coverage detected