On Fri, 8 Jan 2016 at 15:06 'Klaus Aehlig' via ganeti-devel < [email protected]> wrote:
> For standard master failover (with voting), it is necessary > that the majority of nodes is still reachable and can answer > questions about which node is master. Add a predicate verifying > that this is still true. > > Signed-off-by: Klaus Aehlig <[email protected]> > --- > lib/bootstrap.py | 21 +++++++++++++++++++++ > 1 file changed, 21 insertions(+) > > diff --git a/lib/bootstrap.py b/lib/bootstrap.py > index 51924e1..4f0aecf 100644 > --- a/lib/bootstrap.py > +++ b/lib/bootstrap.py > @@ -1290,3 +1290,24 @@ def GatherMasterVotes(node_names): > vote_list.sort(key=lambda x: (x[1], x[0]), reverse=True) > > return vote_list > + > + > +def MajorityHealthy(): > + """Check if the majority of nodes is healthy > + > + Gather master votes from all nodes known to this node; > + return True if a strict majority of nodes is reachable and > + has some opinion on which node is master. Note that this will > + not guarantee any node to win an election but it ensures that > + a standard master-failover is still possible. > + > + """ > + node_names = ssconf.SimpleStore().GetNodeList() > + node_count = len(node_names) > + vote_list = GatherMasterVotes(node_names) > + if vote_list is None: > + return False > + total_votes = sum([count for (node, count) in vote_list if node is not > None]) > + logging.info("Total %d nodes, %d votes: %s", node_count, total_votes, > + vote_list) > + return 2 * total_votes > node_count > -- > 2.6.0.rc2.230.g3dd15c0 > LGTM, thanks -- Helga Velroyen Software Engineer [email protected] Google Germany GmbH Erika-Mann-Strasse 33 80636 München Geschäftsführer: Matthew Scott Sucherman, Paul Terence Manicle Registergericht und -nummer: Hamburg, HRB 86891 Sitz der Gesellschaft: Hamburg Diese E-Mail ist vertraulich. Wenn Sie nicht der richtige Adressat sind, leiten Sie diese bitte nicht weiter, informieren Sie den Absender und löschen Sie die E-Mail und alle Anhänge. Vielen Dank. This e-mail is confidential. If you are not the right addressee please do not forward it, please inform the sender, and please erase this e-mail including any attachments. Thanks.
