mon: Output the real leader in ::_quorum_status() and get_leader_name()

These functions previously assumed the first mon in the quorum
was the leader. That isn't accurate if the first monitor is
disallowed or it lost a connectivity-mode election, though.

Signed-off-by: Greg Farnum <gfarnum@redhat.com>
This commit is contained in:
Greg Farnum 2020-10-29 06:10:23 +00:00
parent 0fd65db3de
commit 50351eac6a
2 changed files with 2 additions and 2 deletions

View File

@ -2580,7 +2580,7 @@ void Monitor::_quorum_status(Formatter *f, ostream& ss)
f->dump_string("mon", *p);
f->close_section(); // quorum_names
f->dump_string("quorum_leader_name", quorum.empty() ? string() : monmap->get_name(*quorum.begin()));
f->dump_string("quorum_leader_name", quorum.empty() ? string() : monmap->get_name(leader));
if (!quorum.empty()) {
f->dump_int(

View File

@ -582,7 +582,7 @@ public:
epoch_t get_epoch();
int get_leader() const { return leader; }
std::string get_leader_name() {
return quorum.empty() ? std::string() : monmap->get_name(*quorum.begin());
return quorum.empty() ? std::string() : monmap->get_name(leader);
}
const std::set<int>& get_quorum() const { return quorum; }
std::list<std::string> get_quorum_names() {