cluster: RHEL56 - resource-agents: Add status_program attribute
by Lon Hohberger
Gitweb: http://git.fedorahosted.org/git/cluster.git?p=cluster.git;a=commitdiff;h=...
Commit: 4c44c6e523a4c8521f55fc7330508c493da379f5
Parent: 7837036cc1b5a5c343a5bd4e041e1f7a91d50086
Author: Lon Hohberger <lhh(a)redhat.com>
AuthorDate: Tue May 4 17:54:15 2010 -0400
Committer: Lon Hohberger <lhh(a)redhat.com>
CommitterDate: Thu May 20 09:50:10 2010 -0400
resource-agents: Add status_program attribute
Resolves: bz583788
Signed-off-by: Lon Hohberger <lhh(a)redhat.com>
---
rgmanager/src/resources/vm.sh | 33 ++++++++++++++++++++++++++++++++-
1 files changed, 32 insertions(+), 1 deletions(-)
diff --git a/rgmanager/src/resources/vm.sh b/rgmanager/src/resources/vm.sh
index d2932dd..2a995eb 100755
--- a/rgmanager/src/resources/vm.sh
+++ b/rgmanager/src/resources/vm.sh
@@ -213,6 +213,20 @@ meta_data()
<content type="string" default="0"/>
</parameter>
+ <parameter name="status_program" reconfig="1">
+ <longdesc lang="en">
+ Ordinarily, only the presence/health of a virtual machine
+ is checked. If specified, the status_program value is
+ executed during a depth 10 check. The intent of this
+ program is to ascertain the status of critical services
+ within a virtual machine.
+ </longdesc>
+ <shortdesc lang="en">
+ Additional status check program
+ </shortdesc>
+ <content type="string" default="0"/>
+ </parameter>
+
<parameter name="hypervisor">
<shortdesc lang="en">
Hypervisor
@@ -255,6 +269,10 @@ meta_data()
<action name="status" timeout="10" interval="30"/>
<action name="monitor" timeout="10" interval="30"/>
+ <!-- depth 10 calls the status_program -->
+ <action name="status" depth="10" timeout="10" interval="300"/>
+ <action name="monitor" depth="10" timeout="10" interval="300"/>
+
<!-- reconfigure - reconfigure with new OCF parameters.
NOT OCF COMPATIBLE AT ALL -->
<action name="reconfig" timeout="10"/>
@@ -543,7 +561,11 @@ virsh_status()
return 0
fi
- return 1
+ if [ "$state" = "shut off" ]; then
+ return $OCF_NOT_RUNNING
+ fi
+
+ return $OCF_ERR_GENERIC
}
@@ -923,6 +945,15 @@ case $1 in
validate_all || exit $OCF_ERR_ARGS
echo -n "Virtual machine $OCF_RESKEY_name is "
do_status
+ rv=$?
+ if [ $rv -ne 0 ]; then
+ exit $rv
+ fi
+ [ -z "$OCF_RESKEY_status_program" ] && exit 0
+ [ -z "$OCF_CHECK_LEVEL" ] && exit 0
+ [ $OCF_CHECK_LEVEL -lt 10 ] && exit 0
+
+ bash -c "$OCF_RESKEY_status_program" &> /dev/null
exit $?
;;
migrate)
13 years, 11 months
cluster: RHEL56 - rgmanager: Add per-resource status check tolerances
by Lon Hohberger
Gitweb: http://git.fedorahosted.org/git/cluster.git?p=cluster.git;a=commitdiff;h=...
Commit: 7837036cc1b5a5c343a5bd4e041e1f7a91d50086
Parent: 39837b7bf28253a21a3ab805e8fedd44b7cb8ca2
Author: Lon Hohberger <lhh(a)redhat.com>
AuthorDate: Tue May 4 17:51:45 2010 -0400
Committer: Lon Hohberger <lhh(a)redhat.com>
CommitterDate: Thu May 20 09:49:43 2010 -0400
rgmanager: Add per-resource status check tolerances
Resolves: bz583788
Signed-off-by: Lon Hohberger <lhh(a)redhat.com>
---
rgmanager/include/reslist.h | 1 +
rgmanager/src/daemons/restree.c | 47 +++++++++++++++++++++++++++++++++++++++
2 files changed, 48 insertions(+), 0 deletions(-)
diff --git a/rgmanager/include/reslist.h b/rgmanager/include/reslist.h
index 0275bfd..001f56b 100644
--- a/rgmanager/include/reslist.h
+++ b/rgmanager/include/reslist.h
@@ -128,6 +128,7 @@ typedef struct _rg_node {
resource_t *rn_resource;
resource_act_t *rn_actions;
restart_counter_t rn_restart_counter;
+ restart_counter_t rn_failure_counter;
int rn_state; /* State of this instance of rn_resource */
int rn_flags;
int rn_last_status;
diff --git a/rgmanager/src/daemons/restree.c b/rgmanager/src/daemons/restree.c
index d5ffea1..3f07f8f 100644
--- a/rgmanager/src/daemons/restree.c
+++ b/rgmanager/src/daemons/restree.c
@@ -565,6 +565,8 @@ do_load_resource(int ccsfd, char *base,
char *ref;
resource_node_t *node;
resource_t *curres;
+ time_t failure_expire = 0;
+ int max_failures = 0;
snprintf(tok, sizeof(tok), "%s/@ref", base);
@@ -659,6 +661,36 @@ do_load_resource(int ccsfd, char *base,
free(ref);
}
+ /* per-resource-node failures / expire times */
+ snprintf(tok, sizeof(tok), "%s/@__max_failures", base);
+#ifndef NO_CCS
+ if (ccs_get(ccsfd, tok, &ref) == 0) {
+#else
+ if (conf_get(tok, &ref) == 0) {
+#endif
+ max_failures = atoi(ref);
+ if (max_failures < 0)
+ max_failures = 0;
+ free(ref);
+ }
+
+ snprintf(tok, sizeof(tok), "%s/@__failure_expire_time", base);
+#ifndef NO_CCS
+ if (ccs_get(ccsfd, tok, &ref) == 0) {
+#else
+ if (conf_get(tok, &ref) == 0) {
+#endif
+ failure_expire = (time_t)expand_time(ref);
+ if ((int64_t)failure_expire < 0)
+ failure_expire = 0;
+ free(ref);
+ }
+
+ if (max_failures && failure_expire) {
+ node->rn_failure_counter = restart_init(failure_expire,
+ max_failures);
+ }
+
curres->r_refs++;
*newnode = node;
@@ -906,6 +938,10 @@ destroy_resource_tree(resource_node_t **tree)
restart_cleanup(node->rn_restart_counter);
}
+ if (node->rn_failure_counter) {
+ restart_cleanup(node->rn_failure_counter);
+ }
+
if(node->rn_actions){
free(node->rn_actions);
}
@@ -1204,6 +1240,15 @@ do_status(resource_node_t *node)
* completed. */
node->rn_actions[idx].ra_last = time(NULL);
+ /* If we have not exceeded our failure count threshold, then fudge
+ * the status check this round */
+ if (x && node->rn_failure_counter) {
+ if (!restart_threshold_exceeded(node->rn_failure_counter)) {
+ x = 0;
+ restart_add(node->rn_failure_counter);
+ }
+ }
+
node->rn_last_status = x;
node->rn_last_depth = node->rn_actions[idx].ra_depth;
node->rn_checked = 1;
@@ -1277,6 +1322,8 @@ clear_checks(resource_node_t *node)
node->rn_actions[x].ra_last = now;
}
+ restart_clear(node->rn_failure_counter);
+
node->rn_checked = 0;
node->rn_last_status = 0;
node->rn_last_depth = 0;
13 years, 11 months
cluster: RHEL56 - rgmanager: Fix max_restart threshold handling
by Lon Hohberger
Gitweb: http://git.fedorahosted.org/git/cluster.git?p=cluster.git;a=commitdiff;h=...
Commit: 39837b7bf28253a21a3ab805e8fedd44b7cb8ca2
Parent: 2c75a3d41764244928b1a83f83a15351d09cdee3
Author: Lon Hohberger <lhh(a)redhat.com>
AuthorDate: Tue May 4 15:03:23 2010 -0400
Committer: Lon Hohberger <lhh(a)redhat.com>
CommitterDate: Thu May 20 09:49:11 2010 -0400
rgmanager: Fix max_restart threshold handling
Max_restart / restart_expire_time was not being correctly
handled, resulting in inconsistent amounts of restarts prior
to relocation (or in some cases, no relocation at all)
Resolves: bz583788
Signed-off-by: Lon Hohberger <lhh(a)redhat.com>
---
rgmanager/include/resgroup.h | 1 +
rgmanager/src/daemons/groups.c | 16 ++++++++++++++++
rgmanager/src/daemons/restart_counter.c | 5 +++++
rgmanager/src/daemons/rg_state.c | 6 +++++-
rgmanager/src/daemons/slang_event.c | 20 ++++++++++++++++++--
5 files changed, 45 insertions(+), 3 deletions(-)
diff --git a/rgmanager/include/resgroup.h b/rgmanager/include/resgroup.h
index ec3e67d..c8e7e2d 100644
--- a/rgmanager/include/resgroup.h
+++ b/rgmanager/include/resgroup.h
@@ -144,6 +144,7 @@ int svc_freeze(char *svcName);
int svc_unfreeze(char *svcName);
int svc_migrate(char *svcName, int target);
int check_restart(char *svcName);
+int clear_restart(const char *rg_name);
int add_restart(char *svcName);
int rt_enqueue_request(const char *resgroupname, int request,
diff --git a/rgmanager/src/daemons/groups.c b/rgmanager/src/daemons/groups.c
index 9caf746..9818aa3 100644
--- a/rgmanager/src/daemons/groups.c
+++ b/rgmanager/src/daemons/groups.c
@@ -1945,6 +1945,22 @@ check_restart(char *rg_name)
return ret;
}
+int
+clear_restart(const char *rg_name)
+{
+ resource_node_t *node;
+ int ret = 0;
+
+ pthread_rwlock_rdlock(&resource_lock);
+ node = node_by_ref(&_tree, rg_name);
+ if (node) {
+ ret = restart_clear(node->rn_restart_counter);
+ }
+ pthread_rwlock_unlock(&resource_lock);
+
+ return ret;
+}
+
void
kill_resource_groups(void)
diff --git a/rgmanager/src/daemons/restart_counter.c b/rgmanager/src/daemons/restart_counter.c
index c889c6d..d909713 100644
--- a/rgmanager/src/daemons/restart_counter.c
+++ b/rgmanager/src/daemons/restart_counter.c
@@ -107,6 +107,11 @@ restart_threshold_exceeded(restart_counter_t arg)
restart_info_t *restarts = (restart_info_t *)arg;
time_t now;
+ if (!arg)
+ /* No max restarts / threshold = always
+ ok to restart! */
+ return 0;
+
VALIDATE(arg, -1);
now = time(NULL);
restart_timer_purge(arg, now);
diff --git a/rgmanager/src/daemons/rg_state.c b/rgmanager/src/daemons/rg_state.c
index 49464d5..3e57748 100644
--- a/rgmanager/src/daemons/rg_state.c
+++ b/rgmanager/src/daemons/rg_state.c
@@ -812,7 +812,6 @@ svc_start(char *svcName, int req)
svcStatus.rs_transition = (uint64_t)time(NULL);
if (svcStatus.rs_state == RG_STATE_RECOVER) {
- add_restart(svcName);
svcStatus.rs_restarts++;
} else {
svcStatus.rs_restarts = 0;
@@ -2143,20 +2142,25 @@ handle_recover_req(char *svcName, int *new_owner)
get_recovery_policy(svcName, policy, sizeof(policy));
if (!strcasecmp(policy, "disable")) {
+ clear_restart(svcName);
return svc_disable(svcName);
} else if (!strcasecmp(policy, "relocate")) {
+ clear_restart(svcName);
return handle_relocate_req(svcName, RG_START_RECOVER, -1,
new_owner);
}
/* Check restart counter/timer for this resource */
if (check_restart(svcName) > 0) {
+ clear_restart(svcName);
clulog(LOG_NOTICE, "Restart threshold for %s exceeded; "
"attempting to relocate\n", svcName);
return handle_relocate_req(svcName, RG_START_RECOVER, -1,
new_owner);
}
+ add_restart(svcName);
+
return handle_start_req(svcName, RG_START_RECOVER, new_owner);
}
diff --git a/rgmanager/src/daemons/slang_event.c b/rgmanager/src/daemons/slang_event.c
index 8a5493c..086ac6b 100644
--- a/rgmanager/src/daemons/slang_event.c
+++ b/rgmanager/src/daemons/slang_event.c
@@ -1123,22 +1123,38 @@ int
S_service_event(const char *file, const char *script, char *name,
int state, int owner, int last_owner)
{
+ char policy[20];
int ret;
_service_name = name;
_service_state = (char *)rg_state_str(state);
_service_owner = owner;
_service_last_owner = last_owner;
- _service_restarts_exceeded = check_restart(name);
+ _service_restarts_exceeded = 0;
switch(state) {
case RG_STATE_DISABLED:
case RG_STATE_STOPPED:
case RG_STATE_FAILED:
- case RG_STATE_RECOVER:
case RG_STATE_ERROR:
/* There is no owner for these states. Ever. */
_service_owner = -1;
+ break;
+ case RG_STATE_RECOVER:
+ get_recovery_policy(name, policy, sizeof(policy));
+ if (!strcasecmp(policy, "restart")) {
+ _service_restarts_exceeded = check_restart(name);
+ add_restart(name);
+ } else if (!strcasecmp(policy, "relocate")) {
+ /* Restart threshold is always exceeded
+ * with 'relocate' recovery policy */
+ _service_restarts_exceeded = 1;
+ }
+ _service_owner = -1;
+ }
+
+ if (_service_restarts_exceeded) {
+ clear_restart(name);
}
ret = do_slang_run(file, script);
13 years, 11 months
cluster: RHEL56 - rgmanager: Fix resource start/check times
by Lon Hohberger
Gitweb: http://git.fedorahosted.org/git/cluster.git?p=cluster.git;a=commitdiff;h=...
Commit: 2c75a3d41764244928b1a83f83a15351d09cdee3
Parent: 1298d52cbc0d32fdc49add7bfe1f8ddf122bc3f0
Author: Lon Hohberger <lhh(a)redhat.com>
AuthorDate: Tue May 4 14:58:58 2010 -0400
Committer: Lon Hohberger <lhh(a)redhat.com>
CommitterDate: Thu May 20 09:48:19 2010 -0400
rgmanager: Fix resource start/check times
Resolves: bz#583788
Signed-off-by: Lon Hohberger <lhh(a)redhat.com>
---
rgmanager/include/reslist.h | 1 -
rgmanager/src/daemons/restree.c | 3 +--
2 files changed, 1 insertions(+), 3 deletions(-)
diff --git a/rgmanager/include/reslist.h b/rgmanager/include/reslist.h
index 4ce3838..0275bfd 100644
--- a/rgmanager/include/reslist.h
+++ b/rgmanager/include/reslist.h
@@ -115,7 +115,6 @@ typedef struct _resource {
char * r_name;
resource_attr_t * r_attrs;
resource_act_t * r_actions;
- time_t r_started; /** Time this resource was last started */
int r_flags;
int r_refs;
int r_incarnations; /** Number of instances running locally */
diff --git a/rgmanager/src/daemons/restree.c b/rgmanager/src/daemons/restree.c
index c4634a5..d5ffea1 100644
--- a/rgmanager/src/daemons/restree.c
+++ b/rgmanager/src/daemons/restree.c
@@ -1265,9 +1265,8 @@ clear_checks(resource_node_t *node)
{
time_t now;
int x = 0;
- resource_t *res = node->rn_resource;
- now = res->r_started;
+ now = get_time((char *)"start", 0, node);
for (; node->rn_actions[x].ra_name; x++) {
13 years, 11 months
cluster: RHEL6 - fence_wti: Add direct support for WTI VMR
by Marek Grác
Gitweb: http://git.fedorahosted.org/git/cluster.git?p=cluster.git;a=commitdiff;h=...
Commit: 6dd191b5a8044c60caba7109b77583b04823bd30
Parent: 9494b5e95ccd681c3f60601b6e306b670c73edbd
Author: Marek 'marx' Grac <mgrac(a)redhat.com>
AuthorDate: Wed May 19 16:25:25 2010 +0200
Committer: Marek 'marx' Grac <mgrac(a)redhat.com>
CommitterDate: Wed May 19 16:28:47 2010 +0200
fence_wti: Add direct support for WTI VMR
Add a new command prompt for WTI VMR devices
Resolves: rhbz#578617
---
fence/agents/wti/fence_wti.py | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/fence/agents/wti/fence_wti.py b/fence/agents/wti/fence_wti.py
index bc25f26..81c0ab9 100644
--- a/fence/agents/wti/fence_wti.py
+++ b/fence/agents/wti/fence_wti.py
@@ -87,7 +87,7 @@ def main():
## Fence agent specific defaults
#####
if 0 == options.has_key("-c"):
- options["-c"] = [ "RSM>", "MPC>", "IPS>", "TPS>", "NBB>", "NPS>" ]
+ options["-c"] = [ "RSM>", "MPC>", "IPS>", "TPS>", "NBB>", "NPS>", "VMR>" ]
docs = { }
docs["shortdesc"] = "Fence agent for WTI"
13 years, 11 months
cluster: STABLE3 - fence_wti: Add direct support for WTI VMR
by Marek Grác
Gitweb: http://git.fedorahosted.org/git/cluster.git?p=cluster.git;a=commitdiff;h=...
Commit: 6b676e1ccc192a6c1396f72b637ba89aa254fd17
Parent: ee52baabd0eb5f187aa33c794e32e9dfd9e637a3
Author: Marek 'marx' Grac <mgrac(a)redhat.com>
AuthorDate: Wed May 19 16:25:25 2010 +0200
Committer: Marek 'marx' Grac <mgrac(a)redhat.com>
CommitterDate: Wed May 19 16:25:25 2010 +0200
fence_wti: Add direct support for WTI VMR
Add a new command prompt for WTI VMR devices
Resolves: rhbz#578617
---
fence/agents/wti/fence_wti.py | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/fence/agents/wti/fence_wti.py b/fence/agents/wti/fence_wti.py
index bc25f26..81c0ab9 100644
--- a/fence/agents/wti/fence_wti.py
+++ b/fence/agents/wti/fence_wti.py
@@ -87,7 +87,7 @@ def main():
## Fence agent specific defaults
#####
if 0 == options.has_key("-c"):
- options["-c"] = [ "RSM>", "MPC>", "IPS>", "TPS>", "NBB>", "NPS>" ]
+ options["-c"] = [ "RSM>", "MPC>", "IPS>", "TPS>", "NBB>", "NPS>", "VMR>" ]
docs = { }
docs["shortdesc"] = "Fence agent for WTI"
13 years, 11 months
cluster: RHEL6 - halvm: Fix bug 593108: lvm agent incorrectly reports vg is in volume_list
by Jonathan Brassow
Gitweb: http://git.fedorahosted.org/git/cluster.git?p=cluster.git;a=commitdiff;h=...
Commit: 9494b5e95ccd681c3f60601b6e306b670c73edbd
Parent: f300d76b20ffc02fdda22ac205eb3b1c8258d544
Author: Jonathan Brassow <jbrassow(a)redhat.com>
AuthorDate: Tue May 18 13:18:53 2010 -0500
Committer: Jonathan Brassow <jbrassow(a)redhat.com>
CommitterDate: Tue May 18 13:22:30 2010 -0500
halvm: Fix bug 593108: lvm agent incorrectly reports vg is in volume_list
If the name of the VG controlled by rgmanager is a substring of the name
of the node, the HA-LVM script will complain of an improper setup.
The fix is to also look for the associated quotes that are necessary when
specifying strings in lvm.conf. Thanks to John Ruemker for the patch.
---
rgmanager/src/resources/lvm.sh | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/rgmanager/src/resources/lvm.sh b/rgmanager/src/resources/lvm.sh
index 4b7155c..7f174ca 100644
--- a/rgmanager/src/resources/lvm.sh
+++ b/rgmanager/src/resources/lvm.sh
@@ -47,7 +47,7 @@ function ha_lvm_proper_setup_check
# lvm.conf:activation/volume_list; otherwise, machines
# will be able to activate the VG regardless of the tags
##
- if lvm dumpconfig activation/volume_list | grep $OCF_RESKEY_vg_name; then
+ if lvm dumpconfig activation/volume_list | grep "\"$OCF_RESKEY_vg_name\""; then
ocf_log err "HA LVM: Improper setup detected"
ocf_log err "- $OCF_RESKEY_vg_name found in \"volume_list\" in lvm.conf"
return $OCF_ERR_GENERIC
13 years, 11 months
cluster: STABLE3 - halvm: Fix bug 506587: lvm agent incorrectly reports vg is in volume_list
by Jonathan Brassow
Gitweb: http://git.fedorahosted.org/git/cluster.git?p=cluster.git;a=commitdiff;h=...
Commit: ee52baabd0eb5f187aa33c794e32e9dfd9e637a3
Parent: b41e5e2a73b8777c26dc51fd1e805bad51eb3203
Author: Jonathan Brassow <jbrassow(a)redhat.com>
AuthorDate: Tue May 18 13:18:53 2010 -0500
Committer: Jonathan Brassow <jbrassow(a)redhat.com>
CommitterDate: Tue May 18 13:18:53 2010 -0500
halvm: Fix bug 506587: lvm agent incorrectly reports vg is in volume_list
If the name of the VG controlled by rgmanager is a substring of the name
of the node, the HA-LVM script will complain of an improper setup.
The fix is to also look for the associated quotes that are necessary when
specifying strings in lvm.conf. Thanks to John Ruemker for the patch.
---
rgmanager/src/resources/lvm.sh | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/rgmanager/src/resources/lvm.sh b/rgmanager/src/resources/lvm.sh
index 4b7155c..7f174ca 100644
--- a/rgmanager/src/resources/lvm.sh
+++ b/rgmanager/src/resources/lvm.sh
@@ -47,7 +47,7 @@ function ha_lvm_proper_setup_check
# lvm.conf:activation/volume_list; otherwise, machines
# will be able to activate the VG regardless of the tags
##
- if lvm dumpconfig activation/volume_list | grep $OCF_RESKEY_vg_name; then
+ if lvm dumpconfig activation/volume_list | grep "\"$OCF_RESKEY_vg_name\""; then
ocf_log err "HA LVM: Improper setup detected"
ocf_log err "- $OCF_RESKEY_vg_name found in \"volume_list\" in lvm.conf"
return $OCF_ERR_GENERIC
13 years, 11 months
cluster: RHEL4 - rgmanager: Kill processes correctly w/ force_unmount
by Lon Hohberger
Gitweb: http://git.fedorahosted.org/git/cluster.git?p=cluster.git;a=commitdiff;h=...
Commit: 6330bbe58b809aaf5dffc4be87e632b427a4b568
Parent: 082a641b2f7122ba86b2773131aa2c77e31680b5
Author: Lon Hohberger <lhh(a)redhat.com>
AuthorDate: Wed Apr 14 17:29:54 2010 -0400
Committer: Lon Hohberger <lhh(a)redhat.com>
CommitterDate: Wed May 5 11:47:07 2010 -0400
rgmanager: Kill processes correctly w/ force_unmount
The killMountProcesses function was written about 10 years ago.
It was designed to work with lsof or fuser, and to log messages
for each process killed. This is not a bad idea. The problem
is that parsing the output of either is and error-prone,
particularly when mountpoints are similar to other directories
on the system.
A far less error-prone method to cleaning up a mount point is to
use 'fuser -kvm' on it. Not only is this less error-prone, it's
a good bit faster at doing its job than iterating through output
in a shell script.
This patch makes force_unmount very reliable at killing the correct
processes, but we lose the logging functionality. It is a fair
trade-off because there have been several bugs in the
killMountProcesses function over the years which have caused several
problems.
Resolves: bz555901
Signed-off-by: Lon Hohberger <lhh(a)redhat.com>
---
rgmanager/src/resources/clusterfs.sh | 113 +--------------------------
rgmanager/src/resources/fs.sh | 140 +++++-----------------------------
rgmanager/src/resources/netfs.sh | 128 +++----------------------------
3 files changed, 37 insertions(+), 344 deletions(-)
diff --git a/rgmanager/src/resources/clusterfs.sh b/rgmanager/src/resources/clusterfs.sh
index bf2a3d1..3ca7a30 100755
--- a/rgmanager/src/resources/clusterfs.sh
+++ b/rgmanager/src/resources/clusterfs.sh
@@ -492,113 +492,6 @@ isAlive()
#
-# killMountProcesses device mount_point
-#
-# Using lsof or fuser try to unmount the mount by killing of the processes
-# that might be keeping it busy.
-#
-killMountProcesses()
-{
- typeset -i ret=$SUCCESS
- typeset have_lsof=""
- typeset have_fuser=""
- typeset try
-
- if [ $# -ne 1 ]; then
- ocf_log err \
- "Usage: killMountProcesses mount_point"
- return $FAIL
- fi
-
- typeset mp=$1
-
- ocf_log notice "Forcefully unmounting $mp"
-
- #
- # Not all distributions have lsof. If not use fuser. If it
- # does, try both.
- #
- file=$(which lsof 2>/dev/null)
- if [ -f "$file" ]; then
- have_lsof=$YES
- fi
-
- file=$(which fuser 2>/dev/null)
- if [ -f "$file" ]; then
- have_fuser=$YES
- fi
-
- if [ -z "$have_lsof" -a -z "$have_fuser" ]; then
- ocf_log warn \
- "Cannot forcefully unmount $mp; cannot find lsof or fuser commands"
- return $FAIL
- fi
-
- for try in 1 2 3; do
- if [ -n "$have_lsof" ]; then
- #
- # Use lsof to free up mount point
- #
- while read command pid user
- do
- if [ -z "$pid" ]; then
- continue
- fi
-
- if [ $try -eq 1 ]; then
- ocf_log warn \
- "killing process $pid ($user $command $mp)"
- elif [ $try -eq 3 ]; then
- ocf_log crit \
- "Could not clean up mountpoint $mp"
- ret=$FAIL
- fi
-
- if [ $try -gt 1 ]; then
- kill -9 $pid
- else
- kill -TERM $pid
- fi
- done < <(lsof -b 2>/dev/null | \
- grep -E "$mp(/.*|)\$" | \
- awk '{print $1,$2,$3}' | \
- sort -u -k 1,3)
- elif [ -n "$have_fuser" ]; then
- #
- # Use fuser to free up mount point
- #
- while read command pid user
- do
- if [ -z "$pid" ]; then
- continue
- fi
-
- if [ $try -eq 1 ]; then
- ocf_log warn \
- "killing process $pid ($user $command $mp)"
- elif [ $try -eq 3 ]; then
- ocf_log crit \
- "Could not clean up mount point $mp"
- ret=$FAIL
- fi
-
- if [ $try -gt 1 ]; then
- kill -9 $pid
- else
- kill -TERM $pid
- fi
- done < <(fuser -vm $mp | \
- grep -v PID | \
- sed 's;^'$mp';;' | \
- awk '{print $4,$2,$1}' | \
- sort -u -k 1,3)
- fi
- done
-
- return $ret
-}
-
-#
# startFilesystem
#
startFilesystem() {
@@ -880,7 +773,11 @@ stop: Could not match $OCF_RESKEY_device with a real device"
umount_failed=yes
if [ "$force_umount" ]; then
- killMountProcesses $mp
+ if [ $try -eq 1 ]; then
+ fuser -TERM -kvm "$mp"
+ else
+ fuser -kvm "$mp"
+ fi
fi
if [ $try -ge $max_tries ]; then
diff --git a/rgmanager/src/resources/fs.sh b/rgmanager/src/resources/fs.sh
index 5b3a3bc..e438894 100755
--- a/rgmanager/src/resources/fs.sh
+++ b/rgmanager/src/resources/fs.sh
@@ -570,6 +570,8 @@ isMounted () {
typeset mp tmp_mp
typeset dev tmp_dev
typeset ret=$FAIL
+ typeset found=1
+ typeset poss_mp
if [ $# -ne 2 ]; then
ocf_log err "Usage: isMounted device mount_point"
@@ -581,7 +583,7 @@ isMounted () {
if [ -z "$dev" ]; then
ocf_log err \
"fs (isMounted): Could not match $1 with a real device"
- return $FAIL
+ return $OCF_ERR_ARGS
fi
if [ -h "$2" ]; then
@@ -607,14 +609,21 @@ isMounted () {
# Check to see if its mounted in the right
# place
#
- if [ -n "$tmp_mp" -a "$tmp_mp" != "$mp" ]; then
- ocf_log warn \
-"Device $dev is mounted on $tmp_mp instead of $mp"
+ if [ -n "$tmp_mp" ]; then
+ if [ "$tmp_mp" != "$mp" ]; then
+ poss_mp=$tmp_mp
+ else
+ found=0
+ fi
fi
ret=$YES
fi
done < /proc/mounts
+ if [ $ret -eq $YES ] && [ $found -ne 0 ]; then
+ ocf_log warn "Device $dev is mounted on $poss_mp instead of $mp"
+ fi
+
return $ret
}
@@ -679,114 +688,6 @@ isAlive()
#
-# killMountProcesses mount_point
-#
-# Using lsof or fuser try to unmount the mount by killing of the processes
-# that might be keeping it busy.
-#
-killMountProcesses()
-{
- typeset -i ret=$SUCCESS
- typeset have_lsof=""
- typeset have_fuser=""
- typeset try
-
- if [ $# -ne 1 ]; then
- ocf_log err \
- "Usage: killMountProcesses mount_point"
- return $FAIL
- fi
-
- typeset mp=$1
-
- ocf_log notice "Forcefully unmounting $mp"
-
- #
- # Not all distributions have lsof. If not use fuser. If it
- # does, try both.
- #
- file=$(which lsof 2>/dev/null)
- if [ -f "$file" ]; then
- have_lsof=$YES
- fi
-
- file=$(which fuser 2>/dev/null)
- if [ -f "$file" ]; then
- have_fuser=$YES
- fi
-
- if [ -z "$have_lsof" -a -z "$have_fuser" ]; then
- ocf_log warn \
- "Cannot forcefully unmount $mp; cannot find lsof or fuser commands"
- return $FAIL
- fi
-
- for try in 1 2 3; do
- if [ -n "$have_lsof" ]; then
- #
- # Use lsof to free up mount point
- #
- while read command pid user
- do
- if [ -z "$pid" ]; then
- continue
- fi
-
- if [ $try -eq 1 ]; then
- ocf_log warn \
- "killing process $pid ($user $command $mp)"
- elif [ $try -eq 3 ]; then
- ocf_log crit \
- "Could not clean up mountpoint $mp"
- ret=$FAIL
- fi
-
- if [ $try -gt 1 ]; then
- kill -9 $pid
- else
- kill -TERM $pid
- fi
- done < <(lsof -bn 2>/dev/null | \
- grep -E "$mp(/.*|)\$" | \
- awk '{print $1,$2,$3}' | \
- sort -u -k 1,3)
- elif [ -n "$have_fuser" ]; then
- #
- # Use fuser to free up mount point
- #
- while read command pid user
- do
- if [ -z "$pid" ]; then
- continue
- fi
-
- if [ $try -eq 1 ]; then
- ocf_log warn \
- "killing process $pid ($user $command $mp)"
- elif [ $try -eq 3 ]; then
- ocf_log crit \
- "Could not clean up mount point $mp"
- ret=$FAIL
- fi
-
- if [ $try -gt 1 ]; then
- kill -9 $pid
- else
- kill -TERM $pid
- fi
- done < <(fuser -vm $mp | \
- grep -v PID | \
- sed 's;^'$mp';;' | \
- awk '{print $4,$2,$1}' | \
- sort -u -k 1,3)
- fi
- done
-
- return $ret
-}
-
-
-#
# Decide which quota options are enabled and return a string
# which we can pass to quotaon
#
@@ -950,7 +851,7 @@ startFilesystem: Creating mount point $mp for device $dev"
;;
$NO) # not mounted, continue
;;
- $FAIL)
+ *)
return $FAIL
;;
esac
@@ -1184,8 +1085,9 @@ stop: Could not match $OCF_RESKEY_device with a real device"
umount_failed=yes
if [ "$force_umount" ]; then
- killMountProcesses $mp
if [ $try -eq 1 ]; then
+ fuser -TERM -kvm "$mp"
+
if [ "$OCF_RESKEY_nfslock" = "yes" ] || \
[ "$OCF_RESKEY_nfslock" = "1" ]; then
ocf_log warning \
@@ -1197,15 +1099,11 @@ stop: Could not match $OCF_RESKEY_device with a real device"
notify_list_store $mp/.clumanager/statd
nfslock_reclaim=1
fi
+ else
+ fuser -kvm "$mp"
fi
fi
- if [ $try -ge $max_tries ]; then
- done=$YES
- else
- sleep $sleep_time
- let try=try+1
- fi
;;
*)
return $FAIL
@@ -1214,7 +1112,7 @@ stop: Could not match $OCF_RESKEY_device with a real device"
if [ $try -ge $max_tries ]; then
done=$YES
- elif [ "$done" -ne "$YES" ]; then
+ elif [ "$done" != "$YES" ]; then
sleep $sleep_time
let try=try+1
fi
diff --git a/rgmanager/src/resources/netfs.sh b/rgmanager/src/resources/netfs.sh
index c683ee6..108d6f3 100755
--- a/rgmanager/src/resources/netfs.sh
+++ b/rgmanager/src/resources/netfs.sh
@@ -349,113 +349,6 @@ isMounted () {
}
#
-# killMountProcesses mount_point
-#
-# Using lsof or fuser try to unmount the mount by killing of the processes
-# that might be keeping it busy.
-#
-killMountProcesses()
-{
- typeset -i ret=$SUCCESS
- typeset have_lsof=""
- typeset have_fuser=""
- typeset try
-
- if [ $# -ne 1 ]; then
- ocf_log err \
- "Usage: killMountProcesses mount_point"
- return $FAIL
- fi
-
- typeset mp=$1
-
- ocf_log notice "Forcefully unmounting $mp"
-
- #
- # Not all distributions have lsof. If not use fuser. If it
- # does, try both.
- #
- file=$(which lsof 2>/dev/null)
- if [ -f "$file" ]; then
- have_lsof=$YES
- fi
-
- file=$(which fuser 2>/dev/null)
- if [ -f "$file" ]; then
- have_fuser=$YES
- fi
-
- if [ -z "$have_lsof" -a -z "$have_fuser" ]; then
- ocf_log warn \
- "Cannot forcefully unmount $mp; cannot find lsof or fuser commands"
- return $FAIL
- fi
-
- for try in 1 2 3; do
- if [ -n "$have_lsof" ]; then
- #
- # Use lsof to free up mount point
- #
- while read command pid user
- do
- if [ -z "$pid" ]; then
- continue
- fi
-
- if [ $try -eq 1 ]; then
- ocf_log warn \
- "killing process $pid ($user $command $mp)"
- elif [ $try -eq 3 ]; then
- ocf_log crit \
- "Could not clean up mountpoint $mp"
- ret=$FAIL
- fi
-
- if [ $try -gt 1 ]; then
- kill -9 $pid
- else
- kill -TERM $pid
- fi
- done < <(lsof -w -bn 2>/dev/null | \
- grep -w -E "$mp(/.*|)\$" | \
- awk '{print $1,$2,$3}' | \
- sort -u -k 1,3)
- elif [ -n "$have_fuser" ]; then
- #
- # Use fuser to free up mount point
- #
- while read command pid user
- do
- if [ -z "$pid" ]; then
- continue
- fi
-
- if [ $try -eq 1 ]; then
- ocf_log warn \
- "killing process $pid ($user $command $mp)"
- elif [ $try -eq 3 ]; then
- ocf_log crit \
- "Could not clean up mount point $mp"
- ret=$FAIL
- fi
-
- if [ $try -gt 1 ]; then
- kill -9 $pid
- else
- kill -TERM $pid
- fi
- done < <(fuser -vm $mp | \
- grep -v PID | \
- sed 's;^'$mp';;' | \
- awk '{print $4,$2,$1}' | \
- sort -u -k 1,3)
- fi
- done
-
- return $ret
-}
-
-#
# startNFSFilesystem
#
startNFSFilesystem() {
@@ -637,15 +530,20 @@ stopNFSFilesystem() {
umount_failed=yes
- if [ "$force_umount" ]; then
- killMountProcesses $mp
- fi
+ if [ "$force_umount" ]; then
+ if [ $try -eq 1 ]; then
+ fuser -TERM -kvm "$mp"
+ else
+ fuser -kvm "$mp"
+ fi
+ fi
- if [ $try -ge $max_tries ]; then
- done=$YES
- else
- sleep $sleep_time
- let try=try+1
+
+ if [ $try -ge $max_tries ]; then
+ done=$YES
+ else
+ sleep $sleep_time
+ let try=try+1
fi
;;
*)
13 years, 11 months
cluster: RHEL4 - Revert "rgmanager: Kill correct PIDs during force_unmount"
by Lon Hohberger
Gitweb: http://git.fedorahosted.org/git/cluster.git?p=cluster.git;a=commitdiff;h=...
Commit: 082a641b2f7122ba86b2773131aa2c77e31680b5
Parent: eb8ab370049d458eae33773826b8f7ece31b21df
Author: Lon Hohberger <lhh(a)redhat.com>
AuthorDate: Wed Apr 14 16:16:21 2010 -0400
Committer: Lon Hohberger <lhh(a)redhat.com>
CommitterDate: Wed Apr 14 16:16:21 2010 -0400
Revert "rgmanager: Kill correct PIDs during force_unmount"
This reverts commit 2d0323010f7110452625bc71c9898459a2ca7e85.
---
rgmanager/src/resources/fs.sh | 27 +++++++++++++--------------
1 files changed, 13 insertions(+), 14 deletions(-)
diff --git a/rgmanager/src/resources/fs.sh b/rgmanager/src/resources/fs.sh
index 46a5189..5b3a3bc 100755
--- a/rgmanager/src/resources/fs.sh
+++ b/rgmanager/src/resources/fs.sh
@@ -690,7 +690,6 @@ killMountProcesses()
typeset have_lsof=""
typeset have_fuser=""
typeset try
- typeset command pid user line
if [ $# -ne 1 ]; then
ocf_log err \
@@ -727,30 +726,30 @@ killMountProcesses()
#
# Use lsof to free up mount point
#
- while read line
+ while read command pid user
do
- path=$(echo $line | awk '{for (i=9;i<NF+1;i++) {printf "%s ",$i};}')
- #if [ -z $(echo $path | grep -E "$mp(/| |$)") ]
- if [ -z $(echo $path | grep -E "^$mp/.*") ]; then
+ if [ -z "$pid" ]; then
continue
fi
- command=$(echo $line | awk '{print $1}')
- pid=$(echo $line | awk '{print $2}')
- user=$(echo $line | awk '{print $3}')
+
if [ $try -eq 1 ]; then
- ocf_log warn "killing process $pid ($user $command $mp)"
+ ocf_log warn \
+ "killing process $pid ($user $command $mp)"
elif [ $try -eq 3 ]; then
- ocf_log crit "Could not clean up mountpoint $mp"
- ret=$FAIL
+ ocf_log crit \
+ "Could not clean up mountpoint $mp"
+ ret=$FAIL
fi
+
if [ $try -gt 1 ]; then
kill -9 $pid
else
kill -TERM $pid
fi
- done< <(lsof -bn 2>/dev/null | \
- grep -E " $mp(/| |$)" | \
- sort -u -k 1,3)
+ done < <(lsof -bn 2>/dev/null | \
+ grep -E "$mp(/.*|)\$" | \
+ awk '{print $1,$2,$3}' | \
+ sort -u -k 1,3)
elif [ -n "$have_fuser" ]; then
#
# Use fuser to free up mount point
13 years, 11 months