Hi,

On Tue, Sep 07, 2010 at 03:55:49PM -0400, Michael Smith wrote:
> Allow the LVM RA to handle multiple volume groups.

Interestingly so far nobody asked for this feature. Can you show
your use case?

> Correct the documentation to refer to volume groups, not volumes.
> 
> Allow "status" operation to skip "vgck" if so configured, in order to
> save time if CLVM is hanging.
> 
> Allow an unsuccessful "stop" to be ignored if so configured, as required
> in some CLVM setups.
> 
> Remove double-check to simplify "validate-all" routine.

Many thanks for the contribution, but I can't accept it as is nor
comment. It needs to be split into several patches, each of them
containing only one functional change or fix.

Cheers,

Dejan

> Signed-off-by: Michael Smith <msm...@cbnco.com>
> 
> --- LVM.7200186935f1-plus-partial     2010-09-07 15:29:42.000000000 -0400
> +++ LVM       2010-08-31 17:27:10.000000000 -0400
> @@ -20,9 +20,6 @@
>  #
>  # See usage() function below for more details...
>  #
> -#      OCF parameters are as below:
> -#            OCF_RESKEY_volgrpname
> -#            
>  #######################################################################
>  # Initialization:
>  
> @@ -38,12 +35,12 @@
>    cat <<-!
>       usage: $0 $methods
>  
> -     $0 manages an  Linux Volume Manager volume (LVM) as an HA resource
> +     $0 manages a Linux Volume Manager (LVM) volume group as an HA resource
>  
> -     The 'start' operation brings the given volume online
> -     The 'stop' operation takes the given volume offline
> -     The 'status' operation reports whether the volume is available
> -     The 'monitor' operation reports whether the volume seems present
> +     The 'start' operation activates all volumes in the group
> +     The 'stop' operation deactivates all volumes in the group
> +     The 'status' operation reports whether at least one LV is available
> +     The 'monitor' operation reports whether the LVM metadata is sane
>       The 'validate-all' operation checks whether the OCF parameters are valid
>       The 'methods' operation reports on the methods $0 supports
>  
> @@ -60,33 +57,65 @@
>  <version>1.0</version>
>  
>  <longdesc lang="en">
> -Resource script for LVM. It manages an  Linux Volume Manager volume (LVM) 
> -as an HA resource. 
> +Resource script for LVM. It makes all logical volumes available on one or 
> more
> +volume groups - useful after clvmd starts up.
>  </longdesc>
> -<shortdesc lang="en">Controls the availability of an LVM Volume 
> Group</shortdesc>
> +<shortdesc lang="en">Makes logical volume groups available</shortdesc>
>  
>  <parameters>
> -<parameter name="volgrpname" unique="0" required="1">
> +<parameter name="volgrpname" unique="0" required="0">
>  <longdesc lang="en">
> -The name of volume group.
> +The name of the volume group. Deprecated - use volgrpnames.
>  </longdesc>
>  <shortdesc lang="en">Volume group name</shortdesc>
>  <content type="string" default="" />
>  </parameter>
> +
> +<parameter name="volgrpnames" unique="0" required="0">
> +<longdesc lang="en">
> +Optional space-separated list of volume group names. If not specified,
> +all volume groups will be used.
> +</longdesc>
> +<shortdesc lang="en">Volume group names</shortdesc>
> +<content type="string" default="" />
> +</parameter>
> +
>  <parameter name="exclusive" unique="0" required="0">
>  <longdesc lang="en">
> -If set, the volume group will be activated exclusively.
> +If set, the volume groups will be activated exclusively.
>  </longdesc>
>  <shortdesc lang="en">Exclusive activation</shortdesc>
>  <content type="string" default="false" />
>  </parameter>
> +
> +<parameter name="vgck" unique="0" required="0">
> +<longdesc lang="en">
> +If true (default), the monitor operation will call vgck in addition to 
> checking
> +status using vgdisplay. You may wish to disable this if you are concerned
> +about timeouts when storage is unavailable.
> +</longdesc>
> +<shortdesc lang="en">Run vgck in monitor operation</shortdesc>
> +<content type="string" default="true" />
> +</parameter>
> +
> +<parameter name="checkstop" unique="0" required="0">
> +<longdesc lang="en">
> +If true (default), the stop operation will verify that the volume groups
> +no longer have any active volumes. You may wish to disable this in a CLVM
> +setup with no exclusive locking, where deactivating the volumes doesn't 
> always
> +work and where failing to deactivate the volumes isn't fatal.
> +</longdesc>
> +<shortdesc lang="en">Check that volume groups have actually 
> stopped</shortdesc>
> +<content type="string" default="true" />
> +</parameter>
> +
>  </parameters>
>  
>  <actions>
> -<action name="start" timeout="30" />
> -<action name="stop" timeout="30" />
> -<action name="status" timeout="30" />
> -<action name="monitor" depth="0" timeout="30" interval="10" />
> +<action name="start" timeout="70" />
> +<action name="stop" timeout="70" />
> +<action name="status" timeout="70" />
> +<action name="monitor" depth="0" timeout="70" interval="10" />
>  <action name="methods" timeout="5" />
>  <action name="meta-data" timeout="5" />
>  <action name="validate-all" timeout="5" />
> @@ -117,10 +146,10 @@
>    if 
>      [ "$LVM_MAJOR" -eq "1" ]
>    then
> -     vgdisplay $1 2>&1 | grep -i 'Status.*available' 2>&1 >/dev/null
> +     vgdisplay $@ 2>&1 | grep -q -i 'Status.*available'
>       return $?
>    else
> -     vgdisplay -v $1 2>&1 | grep -i 'Status[ \t]*available' 2>&1 >/dev/null
> +     vgdisplay -v $@ 2>&1 | grep -q -i 'Status[ \t]*available'
>       return $?
>    fi
>  }
> @@ -133,11 +162,11 @@
>    if 
>      [ "$LVM_MAJOR" -eq "1" ]
>    then
> -     VGOUT=`vgdisplay $1 2>&1`
> +     VGOUT=`vgdisplay $@ 2>&1`
>       echo "$VGOUT" | grep -i 'Status.*available' >/dev/null
>       rc=$?
>    else
> -     VGOUT=`vgdisplay -v $1 2>&1`
> +     VGOUT=`vgdisplay -v $@ 2>&1`
>       echo "$VGOUT" | grep -i 'Status[ \t]*available' >/dev/null
>       rc=$?
>    fi
> @@ -145,18 +174,18 @@
>    if
>      [ $rc -eq 0 ]
>    then
> -    : Volume $1 is available
> +    : Volumes are available
>    else
> -    ocf_log debug "LVM Volume $1 is not available (stopped)"
> +    ocf_log debug "No volumes available (groups: ${@:-all}) (stopped)"
>      return $OCF_NOT_RUNNING
>    fi
>  
>    if
>      echo "$VGOUT" | grep -i 'Access.*read/write' >/dev/null
>    then
> -    ocf_log debug "Volume $1 is available read/write (running)"
> +    ocf_log debug "Volumes are available read/write (running)"
>    else
> -    ocf_log debug "Volume $1 is available read-only (running)"
> +    ocf_log debug "Volumes are available read-only (running)"
>    fi
>    
>    return $OCF_SUCCESS
> @@ -172,13 +201,17 @@
>    then
>      : OK
>    else
> -    ocf_log info "LVM Volume $1 is offline"
> +    ocf_log info "All volumes are offline (groups: ${@:-all})"
>      return $OCF_NOT_RUNNING
>    fi
>  
> -  vgck $1 >/dev/null 2>&1
> -
> -  return $?
> +  if [ -z "$OCF_RESKEY_vgck" ] || ocf_is_true "${OCF_RESKEY_vgck}"
> +  then
> +      vgck $1 >/dev/null 2>&1
> +      return $?
> +  else
> +    return $OCF_SUCCESS
> +  fi
>  }
>  
>  #
> @@ -186,9 +219,7 @@
>  #
>  LVM_start() {
>  
> -  # TODO: This MUST run vgimport as well
> -
> -  ocf_log info "Activating volume group $1"
> +  ocf_log info "Activating logical volumes (groups: ${@:-all})"
>  
>    if [ "$LVM_MAJOR" -eq "1" ]; then
>       ocf_run vgscan $1
> @@ -203,38 +234,66 @@
>  
>  # Activate the VG in partial.
>  # This is needed for mirrored LV
> -  ocf_run vgchange -a $active_mode --partial $1 || return $OCF_ERR_GENERIC
> +  ocf_run vgchange -a $active_mode --partial $@ || return $OCF_ERR_GENERIC
>  
> -  if LVM_status $1; then
> -    : OK Volume $1 activated just fine!
> +  if LVM_status $@; then
> +    : OK Volume $@ activated just fine!
>      return $OCF_SUCCESS 
>    else
> -    ocf_log err "LVM: $1 did not activate correctly"
> +    ocf_log err "LVM: Volume groups (${@:-all}) did not activate correctly"
>      return $OCF_NOT_RUNNING
>    fi
>  }
>  
>  #
> -#    Disable the LVM volume
> +#    Make all volumes unavailable.
>  #
>  LVM_stop() {
>  
> -  vgdisplay "$1" 2>&1 | grep 'Volume group .* not found' >/dev/null && {
> -    ocf_log info "Volume group $1 not found"
> -    return 0
> -  }
> -  ocf_log info "Deactivating volume group $1"
> -  ocf_run vgchange -a ln $1 || return 1
> +  vgs_active=
> +  if [ -z "$@" ]
> +  then
> +    vgdisplay 2>&1 | grep -q 'Volume group .* not found' && {
> +      ocf_log info "No volume groups found"
> +      return $OCF_SUCCESS
> +    }
> +  else
> +    for i in $@
> +    do
> +      if vgdisplay $i 2>&1 | grep -q 'Volume group .* not found'
> +      then
> +        ocf_log info "Volume group $i not found"
> +      else
> +        vgs_active="$vgs $i"
> +      fi
> +
> +      if [ -z "$vgs_active" ]
> +      then
> +        ocf_log info "No volume groups found."
> +        return $OCF_SUCCESS
> +      fi
> +    done
> +  fi
> +
> +  ocf_log info "Deactivating logical volumes (groups: ${vgs_active:-all})"
> +  ocf_run vgchange --available ln $vgs_active
> +  rc=$?
>  
> -  if
> -    LVM_status $1
> +  if [ -z "$OCF_RESKEY_checkstop" ] || ocf_is_true "$OCF_RESKEY_checkstop"
>    then
> -    ocf_log err "LVM: $1 did not stop correctly"
> -    return $OCF_ERR_GENERIC 
> +    if [ $rc -ne 0 ]
> +    then
> +      ocf_log err "Volume groups (${vgs_active:-all}) failed to stop"
> +      return $OCF_ERR_GENERIC
> +    fi
> +
> +    if
> +      LVM_status $1
> +    then
> +      ocf_log err "Volume groups (${vgs_active:-all}) still running after 
> stop"
> +      return $OCF_ERR_GENERIC 
> +    fi
>    fi
> -
> -  # TODO: This MUST run vgexport as well
> -
>    return $OCF_SUCCESS
>  }
>  
> @@ -245,24 +304,10 @@
>    check_binary $AWK
>  
>  #    Off-the-shelf tests...  
> -  vgck "$VOLUME" >/dev/null 2>&1
> +  vgck $@ >/dev/null 2>&1
>    
>    if [ $? -ne 0 ]; then
> -     ocf_log err "Volume group [$VOLUME] does not exist or contains error!"
> -     exit $OCF_ERR_GENERIC
> -  fi
> -
> -#    Double-check
> -  if 
> -    [ "$LVM_MAJOR" -eq "1" ]
> -  then
> -     vgdisplay "$VOLUME" >/dev/null 2>&1
> -  else
> -     vgdisplay -v "$VOLUME" >/dev/null 2>&1
> -  fi
> -
> -  if [ $? -ne 0 ]; then
> -     ocf_log err "Volume group [$VOLUME] does not exist or contains error!"
> +     ocf_log err "Volume groups (${@:-all}) failed vgck!"
>       exit $OCF_ERR_GENERIC
>    fi
>  
> @@ -291,15 +336,6 @@
>    *)         ;;
>  esac
>  
> -if 
> -  [ -z "$OCF_RESKEY_volgrpname" ]
> -then
> -#  echo "You must identify the volume group name!"
> -  ocf_log err "You must identify the volume group name!"
> -#  usage
> -  exit $OCF_ERR_ARGS 
> -fi
> -
>  # Get the LVM version number, for this to work we assume(thanks to panjiam):
>  # 
>  # LVM1 outputs like this
> @@ -328,26 +364,26 @@
>  fi
>  LVM_MAJOR="${LVM_VERSION%%.*}"
>  
> -VOLUME=$OCF_RESKEY_volgrpname
> +VOLUMES="$OCF_RESKEY_volgrpname $OCF_RESKEY_volgrpnames"
>  
>  # What kind of method was invoked?
>  case "$1" in
>  
> -  start)     LVM_start $VOLUME
> +  start)     LVM_start $VOLUMES
>               exit $?;;
>  
> -  stop)              LVM_stop $VOLUME
> +  stop)              LVM_stop $VOLUMES
>               exit $?;;
>  
> -  status)    LVM_report_status $VOLUME
> +  status)    LVM_report_status $VOLUMES
>               exit $?;;
>  
> -  monitor)   LVM_monitor $VOLUME
> +  monitor)   LVM_monitor $VOLUMES
>               exit $?;;
>  
> -  validate-all)      LVM_validate_all
> +  validate-all)      LVM_validate_all $VOLUMES
>               ;;
>  
>    *)         usage
> -             exit $OCF_ERR_AEGS;;
> +             exit $OCF_ERR_ARGS;;
>  esac
> _______________________________________________________
> Linux-HA-Dev: Linux-HA-Dev@lists.linux-ha.org
> http://lists.linux-ha.org/mailman/listinfo/linux-ha-dev
> Home Page: http://linux-ha.org/
_______________________________________________________
Linux-HA-Dev: Linux-HA-Dev@lists.linux-ha.org
http://lists.linux-ha.org/mailman/listinfo/linux-ha-dev
Home Page: http://linux-ha.org/

Reply via email to