On Wed, Jan 15, 2014 at 10:50 AM, Jose A. Lopes <[email protected]> wrote:
> * RPC 'GetMasterInfo' returns several fields, namely, 'master_netdev',
>   'master_ip', 'master_netmask', 'master_node', and
>   'primary_ip_family', of which only the 'master_node' is actually
>   used.  This patch, removes all the other fields and keeps only the
>   'master_node' field.
>
> * Simplify the the voting algorithm code.
>
> Signed-off-by: Jose A. Lopes <[email protected]>
> ---
>  lib/backend.py   | 16 ++++------------
>  lib/bootstrap.py | 27 +++++++++------------------
>  2 files changed, 13 insertions(+), 30 deletions(-)
>
> diff --git a/lib/backend.py b/lib/backend.py
> index c37e01d..56e1f6e 100644
> --- a/lib/backend.py
> +++ b/lib/backend.py
> @@ -284,28 +284,20 @@ def JobQueuePurge():
>
>
>  def GetMasterInfo():
> -  """Returns master information.
> +  """Returns information about master node.
>

Please replace this with:

"Returns the master node name."
It might even make sense to just change the rpc call name altogether.

>    This is an utility function to compute master information, either
>    for consumption here or from the node daemon.
>
> -  @rtype: tuple
> -  @return: master_netdev, master_ip, master_name, primary_ip_family,
> -    master_netmask
> +  @rtype: string
> +  @return: name of the master node
>    @raise RPCFail: in case of errors
>
>    """
>    try:
> -    cfg = _GetConfig()
> -    master_netdev = cfg.GetMasterNetdev()
> -    master_ip = cfg.GetMasterIP()
> -    master_netmask = cfg.GetMasterNetmask()
> -    master_node = cfg.GetMasterNode()
> -    primary_ip_family = cfg.GetPrimaryIPFamily()
> +    return _GetConfig().GetMasterNode()
>    except errors.ConfigurationError, err:
>      _Fail("Cluster configuration incomplete: %s", err, exc=True)
> -  return (master_netdev, master_ip, master_node, primary_ip_family,
> -          master_netmask)
>
>
>  def RunLocalHooks(hook_opcode, hooks_path, env_builder_fn):
> diff --git a/lib/bootstrap.py b/lib/bootstrap.py
> index e468283..6029059 100644
> --- a/lib/bootstrap.py
> +++ b/lib/bootstrap.py
> @@ -1119,27 +1119,18 @@ def GatherMasterVotes(node_names):
>    votes = {}
>    for node_name in results:
>      nres = results[node_name]
> -    data = nres.payload
>      msg = nres.fail_msg
> -    fail = False
> +
>      if msg:
>        logging.warning("Error contacting node %s: %s", node_name, msg)
> -      fail = True
> -    # for now we accept both length 3, 4 and 5 (data[3] is primary ip version
> -    # and data[4] is the master netmask)
> -    elif not isinstance(data, (tuple, list)) or len(data) < 3:
> -      logging.warning("Invalid data received from node %s: %s",
> -                      node_name, data)
> -      fail = True
> -    if fail:
> -      if None not in votes:
> -        votes[None] = 0
> -      votes[None] += 1
> -      continue
> -    master_node = data[2]
> -    if master_node not in votes:
> -      votes[master_node] = 0
> -    votes[master_node] += 1
> +      node = None
> +    else:
> +      node = nres.payload
> +
> +    if node not in votes:
> +      votes[node] = 1
> +    else:
> +      votes[node] += 1
>
>    vote_list = [v for v in votes.items()]
>    # sort first on number of votes then on name, since we want None
> --
> 1.8.5.2
>

rest LGTM

Thanks,

Guido




--
Guido Trotter
Ganeti Engineering
Google Germany GmbH
Dienerstr. 12, 80331, München

Registergericht und -nummer: Hamburg, HRB 86891
Sitz der Gesellschaft: Hamburg
Geschäftsführer: Graham Law, Christine Elizabeth Flores
Steuernummer: 48/725/00206
Umsatzsteueridentifikationsnummer: DE813741370


-- 
Guido Trotter
Ganeti Engineering
Google Germany GmbH
Dienerstr. 12, 80331, München

Registergericht und -nummer: Hamburg, HRB 86891
Sitz der Gesellschaft: Hamburg
Geschäftsführer: Graham Law, Christine Elizabeth Flores
Steuernummer: 48/725/00206
Umsatzsteueridentifikationsnummer: DE813741370

Reply via email to