LGTM, thanks!

On Tue, Dec 17, 2013 at 10:28 AM, Santi Raffa <[email protected]> wrote:

> Add support for the QEMU gluster: protocol. Also change the access
> mode routines so they check the access parameter for all templates.
>
> Signed-off-by: Santi Raffa <[email protected]>
> ---
>  doc/install.rst         |   23 +++++++++++++++++++++++
>  lib/cmdlib/common.py    |   26 ++++++++++++--------------
>  lib/config.py           |   10 +++++++---
>  lib/storage/gluster.py  |   13 +++++++++++++
>  src/Ganeti/Constants.hs |    5 +++++
>  5 files changed, 60 insertions(+), 17 deletions(-)
>
> diff --git a/doc/install.rst b/doc/install.rst
> index 2b4551a..dd8b38b 100644
> --- a/doc/install.rst
> +++ b/doc/install.rst
> @@ -418,6 +418,29 @@ only need to specify the IP addresses of the RADOS
> Cluster monitors.
>  For more information, please see the `Ceph Docs
>  <http://ceph.newdream.net/docs/latest/>`_
>
> +Installing Gluster
> +++++++++++++++++++
> +
> +For Gluster integration, Ganeti requires that ``mount.glusterfs`` is
> +installed on each and every node. On Debian Wheezy and newer, you can
> +satisfy this requirement with the ``glusterfs-client`` package; see
> +`this guide
> +<
> http://gluster.org/community/documentation/index.php/Gluster_3.2:_Installing_the_Gluster_Native_Client
> >`_
> +for details.
> +
> +KVM userspace access
> +~~~~~~~~~~~~~~~~~~~~
> +
> +If your cluster uses a sufficiently new version of KVM (you will need at
> +least QEMU 1.3 with Gluster support compiled in), you can take advantage
> +of KVM's native support for gluster in order to have better performance
> +and avoid potential deadlocks in low memory scenarios.
> +
> +Please be aware that QEMU 1.3 was released in December 3, 2012, and as
> +such this feature is not available out of the box in any distribution
> +older than Ubuntu 13.04; this excludes Ubuntu 12.04 LTS and Debian
> +Wheezy.
> +
>  Other required software
>  +++++++++++++++++++++++
>
> diff --git a/lib/cmdlib/common.py b/lib/cmdlib/common.py
> index 5a1a017..8dc09d1 100644
> --- a/lib/cmdlib/common.py
> +++ b/lib/cmdlib/common.py
> @@ -1142,14 +1142,14 @@ def CheckDiskAccessModeValidity(parameters):
>    @raise errors.OpPrereqError: if the check fails.
>
>    """
> -  if constants.DT_RBD in parameters:
> -    access = parameters[constants.DT_RBD].get(constants.RBD_ACCESS,
> -                                              constants.DISK_KERNELSPACE)
> +  for disk_template in parameters:
> +    access = parameters[disk_template].get(constants.LDP_ACCESS,
> +                                           constants.DISK_KERNELSPACE)
>      if access not in constants.DISK_VALID_ACCESS_MODES:
>        valid_vals_str = utils.CommaJoin(constants.DISK_VALID_ACCESS_MODES)
>        raise errors.OpPrereqError("Invalid value of '{d}:{a}': '{v}'
> (expected"
> -                                 " one of {o})".format(d=constants.DT_RBD,
> -
> a=constants.RBD_ACCESS,
> +                                 " one of {o})".format(d=disk_template,
> +
> a=constants.LDP_ACCESS,
>                                                         v=access,
>                                                         o=valid_vals_str))
>
> @@ -1170,9 +1170,12 @@ def CheckDiskAccessModeConsistency(parameters, cfg,
> group=None):
>    """
>    CheckDiskAccessModeValidity(parameters)
>
> -  if constants.DT_RBD in parameters:
> -    access = parameters[constants.DT_RBD].get(constants.RBD_ACCESS,
> -                                              constants.DISK_KERNELSPACE)
> +  for disk_template in parameters:
> +    access = parameters[disk_template].get(constants.LDP_ACCESS,
> +                                           constants.DISK_KERNELSPACE)
> +
> +    if dt not in constants.DTS_HAVE_ACCESS
> +      continue
>
>      #Check the combination of instance hypervisor, disk template and
> access
>      #protocol is sane.
> @@ -1180,15 +1183,10 @@ def CheckDiskAccessModeConsistency(parameters,
> cfg, group=None):
>                   cfg.GetInstanceList()
>
>      for entry in inst_uuids:
> -      #hyp, disk, access
>        inst = cfg.GetInstanceInfo(entry)
>        hv = inst.hypervisor
>        dt = inst.disk_template
>
> -      #do not check for disk types that don't have this setting.
> -      if dt != constants.DT_RBD:
> -        continue
> -
>        if not IsValidDiskAccessModeCombination(hv, dt, access):
>          raise errors.OpPrereqError("Instance {i}: cannot use '{a}' access"
>                                     " setting with {h} hypervisor and {d}
> disk"
> @@ -1212,7 +1210,7 @@ def IsValidDiskAccessModeCombination(hv,
> disk_template, mode):
>      return True
>
>    if (hv == constants.HT_KVM and
> -      disk_template == constants.DT_RBD and
> +      disk_template in (constants.DT_RBD, constants.DT_GLUSTER) and
>        mode == constants.DISK_USERSPACE):
>      return True
>
> diff --git a/lib/config.py b/lib/config.py
> index 5b4b1a3..c1fa5df 100644
> --- a/lib/config.py
> +++ b/lib/config.py
> @@ -678,12 +678,16 @@ class ConfigWriter(object):
>              constants.NDS_PARAMETER_TYPES)
>      _helper_ipolicy("cluster", cluster.ipolicy, True)
>
> -    if constants.DT_RBD in cluster.diskparams:
> -      access = cluster.diskparams[constants.DT_RBD][constants.RBD_ACCESS]
> +    for disk_template in cluster.diskparams:
> +      if disk_template not in constants.DTS_HAVE_ACCESS:
> +        continue
> +
> +      access = cluster.diskparams[disk_template].get(constants.LDP_ACCESS,
> +
> constants.DISK_KERNELSPACE)
>        if access not in constants.DISK_VALID_ACCESS_MODES:
>          result.append(
>            "Invalid value of '%s:%s': '%s' (expected one of %s)" % (
> -            constants.DT_RBD, constants.RBD_ACCESS, access,
> +            disk_template, constants.LDP_ACCESS, access,
>              utils.CommaJoin(constants.DISK_VALID_ACCESS_MODES)
>            )
>          )
> diff --git a/lib/storage/gluster.py b/lib/storage/gluster.py
> index e8f485d..2392e6c 100644
> --- a/lib/storage/gluster.py
> +++ b/lib/storage/gluster.py
> @@ -403,6 +403,19 @@ class GlusterStorage(base.BlockDev):
>      """
>      return self.file.Size()
>
> +  def GetUserspaceAccessUri(self, hypervisor):
> +    """Generate KVM userspace URIs to be used as `-drive file` settings.
> +
> +    @see: L{BlockDev.GetUserspaceAccessUri}
> +    @see:
> https://github.com/qemu/qemu/commit/8d6d89cb63c57569864ecdeb84d3a1c2eb
> +    """
> +
> +    if hypervisor == constants.HT_KVM:
> +      return self.volume.GetKVMMountString(self.path)
> +    else:
> +      base.ThrowError("Hypervisor %s doesn't support Gluster userspace
> access" %
> +                      hypervisor)
> +
>    @classmethod
>    def Create(cls, unique_id, children, size, spindles, params, excl_stor,
>               dyn_params):
> diff --git a/src/Ganeti/Constants.hs b/src/Ganeti/Constants.hs
> index 654429e..fa7ccf7 100644
> --- a/src/Ganeti/Constants.hs
> +++ b/src/Ganeti/Constants.hs
> @@ -896,6 +896,11 @@ dtsBlock =
>  dtsLvm :: FrozenSet String
>  dtsLvm = diskTemplates `ConstantUtils.difference` dtsNotLvm
>
> +-- | The set of lvm-based disk templates
> +dtsHaveAccess :: FrozenSet String
> +dtsHaveAccess = ConstantUtils.mkSet $
> +  map Types.diskTemplateToRaw [DTRbd, DTGluster]
> +
>  -- * Drbd
>
>  drbdHmacAlg :: String
> --
> 1.7.10.4
>
>


-- 
Thomas Thrainer | Software Engineer | [email protected] |

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

Reply via email to