On Wed, Jul 3, 2013 at 6:45 PM, Helga Velroyen <[email protected]> wrote:

> This patch fixes two problems with the storage reporting
> that showed up in the QA for exclusive storage:
>
> - The processing of storage space information for instance
>   operations wrongly assumed that the volume group's
>   storage information is always the first in the list.
> - The storage parameter 'exclusive storage' was not
>   correctly extracted from the list of storage parameters.
>
> Signed-off-by: Helga Velroyen <[email protected]>
> ---
> Note: In order to not break the build in between, I will
> need to squash this patch with the patch "Fix preparation
> of storage units in allocator". I'll compose the commit
> message from both of them.
>
>  lib/backend.py                 | 25 ++++++++++++++++++++++++-
>  lib/cmdlib/instance_storage.py |  8 ++++++--
>  2 files changed, 30 insertions(+), 3 deletions(-)
>
> diff --git a/lib/backend.py b/lib/backend.py
> index aea6db3..09b9984 100644
> --- a/lib/backend.py
> +++ b/lib/backend.py
> @@ -573,6 +573,29 @@ def LeaveCluster(modify_ssh_setup):
>    raise errors.QuitGanetiException(True, "Shutdown scheduled")
>
>
> +def _GetLvmVgSpaceInfo(name, params):
> +  """Wrapper around C{_GetVgInfo} which checks the storage parameters.
> +
> +  @type name: string
> +  @param name: name of the volume group
> +  @type params: list
> +  @param params: list of storage parameters, which in this case should be
> +    containing only one for exclusive storage
> +
> +  """
> +  if params is None:
> +    raise errors.ProgrammerError("No storage parameter for LVM vg storage"
> +                                 " reporting is provided.")
> +  if not isinstance(params, list):
> +    raise errors.ProgrammerError("The storage parameters are not of type"
> +                                 " list: '%s'" % params)
> +  if not len(params) == 1:
> +    raise errors.ProgrammerError("Received more than one storage
> parameter:"
> +                                 " '%s'" % params)
> +  excl_stor = bool(params[0])
> +  return _GetVgInfo(name, excl_stor)
> +
> +
>  def _GetVgInfo(name, excl_stor):
>    """Retrieves information about a LVM volume group.
>
> @@ -714,7 +737,7 @@ _STORAGE_TYPE_INFO_FN = {
>    constants.ST_EXT: None,
>    constants.ST_FILE: _GetFileStorageSpaceInfo,
>    constants.ST_LVM_PV: _GetVgSpindlesInfo,
> -  constants.ST_LVM_VG: _GetVgInfo,
> +  constants.ST_LVM_VG: _GetLvmVgSpaceInfo,
>    constants.ST_RADOS: None,
>  }
>
> diff --git a/lib/cmdlib/instance_storage.py
> b/lib/cmdlib/instance_storage.py
> index f92eaaa..8b1db31 100644
> --- a/lib/cmdlib/instance_storage.py
> +++ b/lib/cmdlib/instance_storage.py
> @@ -905,8 +905,12 @@ def _CheckNodesFreeDiskOnVG(lu, node_uuids, vg,
> requested):
>      info = nodeinfo[node]
>      info.Raise("Cannot get current information from node %s" % node_name,
>                 prereq=True, ecode=errors.ECODE_ENVIRON)
> -    (_, (vg_info, ), _) = info.payload
> -    vg_free = vg_info.get("storage_free", None)
> +    (_, space_info, _) = info.payload
> +    lvm_vg_info = utils.storage.LookupSpaceInfoByStorageType(
> +        space_info, constants.ST_LVM_VG)
> +    if not lvm_vg_info:
> +      raise errors.OpPrereqError("Can't retrieve storage information for
> LVM")
> +    vg_free = lvm_vg_info.get("storage_free", None)
>      if not isinstance(vg_free, int):
>        raise errors.OpPrereqError("Can't compute free disk space on node"
>                                   " %s for vg %s, result was '%s'" %
> --
> 1.8.3
>
>
LGTM, thanks.

Reply via email to