Gitweb:
http://git.fedorahosted.org/git/cluster.git?p=cluster.git;a=commitdiff;h=...
Commit: 90194b38e88b7efdbe7a784aba2393259c135c5d
Parent: bdf7691f84eac400323c84a490f0147ec851afdf
Author: Jonathan Brassow <jbrassow(a)redhat.com>
AuthorDate: Thu Apr 26 18:05:50 2012 -0500
Committer: Jonathan Brassow <jbrassow(a)redhat.com>
CommitterDate: Thu Apr 26 18:05:50 2012 -0500
Bring HA LVM inline with upstream to collect the fixes there.
Most fixes revolve around the manipulation of tags and improving
the robustness of handling failure scenarios.
---
rgmanager/src/resources/lvm.sh | 37 +++++++++++++++----
rgmanager/src/resources/lvm_by_lv.sh | 63 +++++++++++++++------------------
rgmanager/src/resources/lvm_by_vg.sh | 37 +++++++++++++++-----
3 files changed, 86 insertions(+), 51 deletions(-)
diff --git a/rgmanager/src/resources/lvm.sh b/rgmanager/src/resources/lvm.sh
index 0ffcadf..1e2c93b 100755
--- a/rgmanager/src/resources/lvm.sh
+++ b/rgmanager/src/resources/lvm.sh
@@ -42,6 +42,33 @@ rv=0
function ha_lvm_proper_setup_check
{
##
+ # Does the Volume Group exist?
+ # 1) User may have forgotten to create it
+ # 2) User may have misspelled it in the config file
+ ##
+ if ! vgs $OCF_RESKEY_vg_name --config 'global{locking_type=0}'>&
/dev/null; then
+ ocf_log err "HA LVM: Unable to get volume group attributes for
$OCF_RESKEY_vg_name"
+ return $OCF_ERR_GENERIC
+ fi
+
+ ##
+ # Are we using the "tagging" or "CLVM" variant?
+ # The CLVM variant will have the cluster attribute set
+ ##
+ if [[ $(vgs -o attr --noheadings --config 'global{locking_type=0}'
$OCF_RESKEY_vg_name 2>/dev/null) =~ .....c ]]; then
+ # Is clvmd running?
+ if ! ps -C clvmd >& /dev/null; then
+ ocf_log err "HA LVM: $OCF_RESKEY_vg_name has the cluster attribute set, but
'clvmd' is not running"
+ return $OCF_ERR_GENERIC
+ fi
+ return $OCF_SUCCESS
+ fi
+
+ ##
+ # The "tagging" variant is being used if we have gotten this far.
+ ##
+
+ ##
# The default for lvm.conf:activation/volume_list is empty,
# this must be changed for HA LVM.
##
@@ -93,9 +120,7 @@ function ha_lvm_proper_setup_check
case $1 in
start)
- if ! [[ $(vgs -o attr --noheadings $OCF_RESKEY_vg_name) =~ .....c ]]; then
- ha_lvm_proper_setup_check || exit 1
- fi
+ ha_lvm_proper_setup_check || exit 1
if [ -z $OCF_RESKEY_lv_name ]; then
vg_start || exit 1
@@ -115,11 +140,7 @@ status|monitor)
;;
stop)
- if ! [[ $(vgs -o attr --noheadings $OCF_RESKEY_vg_name) =~ .....c ]]; then
- if ! ha_lvm_proper_setup_check; then
- ocf_log err "WARNING: An improper setup can cause data corruption!"
- fi
- fi
+ ha_lvm_proper_setup_check
if [ -z $OCF_RESKEY_lv_name ]; then
vg_stop || exit 1
diff --git a/rgmanager/src/resources/lvm_by_lv.sh b/rgmanager/src/resources/lvm_by_lv.sh
index 966214f..4971173 100644
--- a/rgmanager/src/resources/lvm_by_lv.sh
+++ b/rgmanager/src/resources/lvm_by_lv.sh
@@ -320,45 +320,40 @@ lv_activate()
if ! lv_activate_and_tag $1 $my_name $lv_path; then
ocf_log err "Failed to $1 $lv_path"
- if [ "$1" == "start" ]; then
- ocf_log notice "Attempting cleanup of $OCF_RESKEY_vg_name"
-
- if vgreduce --removemissing --config \
- "activation { volume_list = \"$OCF_RESKEY_vg_name\" }" \
- $OCF_RESKEY_vg_name; then
- ocf_log notice "$OCF_RESKEY_vg_name now consistent"
- owner=`lvs -o tags --noheadings $lv_path`
- if [ ! -z $owner ] && [ $owner != $my_name ]; then
- if is_node_member_clustat $owner ; then
- ocf_log err "$owner owns $lv_path unable to $1"
- return $OCF_ERR_GENERIC
- fi
- ocf_log notice "Owner of $lv_path is not in the cluster"
- ocf_log notice "Stealing $lv_path"
-
- lvchange --deltag $owner $lv_path
- if [ $? -ne 0 ]; then
- ocf_log err "Failed to steal $lv_path from $owner"
- return $OCF_ERR_GENERIC
- fi
-
- # Warning --deltag doesn't always result in failure
- if [ ! -z `lvs -o tags --noheadings $lv_path` ]; then
- ocf_log err "Failed to steal $lv_path from $owner."
- return $OCF_ERR_GENERIC
- fi
+ ocf_log notice "Attempting cleanup of $OCF_RESKEY_vg_name"
+
+ if vgreduce --removemissing --force --config \
+ "activation { volume_list = \"$OCF_RESKEY_vg_name\" }" \
+ $OCF_RESKEY_vg_name; then
+ ocf_log notice "$OCF_RESKEY_vg_name now consistent"
+ owner=`lvs -o tags --noheadings $lv_path`
+ if [ ! -z $owner ] && [ $owner != $my_name ]; then
+ if is_node_member_clustat $owner ; then
+ ocf_log err "$owner owns $lv_path unable to $1"
+ return $OCF_ERR_GENERIC
fi
+ ocf_log notice "Owner of $lv_path is not in the cluster"
+ ocf_log notice "Stealing $lv_path"
- if ! lv_activate_and_tag $1 $my_name $lv_path; then
- ocf_log err "Failed second attempt to $1 $lv_path"
+ lvchange --deltag $owner $lv_path
+ if [ $? -ne 0 ]; then
+ ocf_log err "Failed to steal $lv_path from $owner"
return $OCF_ERR_GENERIC
- else
- ocf_log notice "Second attempt to $1 $lv_path successful"
- return $OCF_SUCCESS
fi
- else
- ocf_log err "Failed to make $OCF_RESKEY_vg_name consistent"
+
+ # Warning --deltag doesn't always result in failure
+ if [ ! -z `lvs -o tags --noheadings $lv_path` ]; then
+ ocf_log err "Failed to steal $lv_path from $owner."
+ return $OCF_ERR_GENERIC
+ fi
+ fi
+
+ if ! lv_activate_and_tag $1 $my_name $lv_path; then
+ ocf_log err "Failed second attempt to $1 $lv_path"
return $OCF_ERR_GENERIC
+ else
+ ocf_log notice "Second attempt to $1 $lv_path successful"
+ return $OCF_SUCCESS
fi
else
ocf_log err "Failed to $1 $lv_path"
diff --git a/rgmanager/src/resources/lvm_by_vg.sh b/rgmanager/src/resources/lvm_by_vg.sh
index 08d8c98..0dd2aaa 100755
--- a/rgmanager/src/resources/lvm_by_vg.sh
+++ b/rgmanager/src/resources/lvm_by_vg.sh
@@ -50,7 +50,7 @@ function vg_owner
return 1
}
-function strip_tags
+function _strip_tags
{
local i
@@ -67,6 +67,29 @@ function strip_tags
return $OCF_SUCCESS
}
+function strip_tags
+{
+ if ! _strip_tags; then
+ ocf_log notice "Attempting cleanup of $OCF_RESKEY_vg_name"
+
+ if ! vgreduce --removemissing --force --config \
+ "activation { volume_list = \"$OCF_RESKEY_vg_name\" }" \
+ $OCF_RESKEY_vg_name; then
+
+ ocf_log err "Failed to make $OCF_RESKEY_vg_name consistent"
+ return $OCF_ERR_GENERIC
+ fi
+
+ ocf_log notice "Cleanup of $OCF_RESKEY_vg_name successful"
+ fi
+ if ! _strip_tags; then
+ ocf_log err "Failed 2nd attempt to remove tags from, $OCF_RESKEY_vg_name"
+ return $OCF_ERR_GENERIC
+ fi
+
+ return $OCF_SUCCESS
+}
+
function strip_and_add_tag
{
if ! strip_tags; then
@@ -179,7 +202,7 @@ function vg_start_clustered
ocf_log err "Failed to activate volume group, $OCF_RESKEY_vg_name"
ocf_log notice "Attempting cleanup of $OCF_RESKEY_vg_name"
- if ! vgreduce --removemissing $OCF_RESKEY_vg_name; then
+ if ! vgreduce --removemissing --force $OCF_RESKEY_vg_name; then
ocf_log err "Failed to make $OCF_RESKEY_vg_name consistent"
return $OCF_ERR_GENERIC
fi
@@ -257,7 +280,7 @@ function vg_start_single
ocf_log err "Failed to activate volume group, $OCF_RESKEY_vg_name"
ocf_log notice "Attempting cleanup of $OCF_RESKEY_vg_name"
- if ! vgreduce --removemissing --config \
+ if ! vgreduce --removemissing --force --config \
"activation { volume_list = \"$OCF_RESKEY_vg_name\" }" \
$OCF_RESKEY_vg_name; then
@@ -265,11 +288,7 @@ function vg_start_single
return $OCF_ERR_GENERIC
fi
- vg_owner
- if [ $? -eq 0 ]; then
- ocf_log err "Unable to claim ownership of $OCF_RESKEY_vg_name"
- return $OCF_ERR_GENERIC
- fi
+ ocf_log notice "Cleanup of $OCF_RESKEY_vg_name successful"
if ! strip_and_add_tag ||
! vgchange -ay $OCF_RESKEY_vg_name; then
@@ -282,7 +301,7 @@ function vg_start_single
else
# The activation commands succeeded, but did they do anything?
# Make sure all the logical volumes are active
- results=(`lvs -o name,attr --noheadings 2> /dev/null $OCF_RESKEY_vg_name`)
+ results=(`lvs -o name,attr --noheadings $OCF_RESKEY_vg_name 2> /dev/null`)
a=0
while [ ! -z ${results[$a]} ]; do
if [[ ! ${results[$(($a + 1))]} =~ ....a. ]]; then