* [Cluster-devel] [PATCH] Med: Improve script.sh's error reporting (RHEL6)
@ 2012-11-26 15:23 Lon Hohberger
2012-11-29 20:28 ` Lon Hohberger
0 siblings, 1 reply; 2+ messages in thread
From: Lon Hohberger @ 2012-11-26 15:23 UTC (permalink / raw)
To: cluster-devel.redhat.com
The script agent used primarily by rgmanager had a very minimal amount
of error reporting, such that it could be very confusing as to why a
script resource had failed.
This patch looks for a variety of errors from the script resource.
Resolves: rhbz#773478
Signed-off-by: Lon Hohberger <lhh@redhat.com>
---
rgmanager/src/resources/script.sh | 57 ++++++++++++++++++++++++++++++++++--
1 files changed, 53 insertions(+), 4 deletions(-)
diff --git a/rgmanager/src/resources/script.sh b/rgmanager/src/resources/script.sh
index fa07f1d..be65afc 100755
--- a/rgmanager/src/resources/script.sh
+++ b/rgmanager/src/resources/script.sh
@@ -94,21 +94,70 @@ meta_data()
EOT
}
+validate_or_exit()
+{
+ if [ -z "${OCF_RESKEY_file}" ]; then
+ ocf_log err "No file provided"
+ exit $OCF_ERR_ARGS # Invalid Argument
+ fi
+
+ if ! [ -e "${OCF_RESKEY_file}" ]; then
+ ocf_log err "${OCF_RESKEY_file} does not exist"
+ exit $OCF_ERR_INSTALLED # Program not installed
+ fi
+
+ if [ -b "${OCF_RESKEY_file}" ]; then
+ ocf_log err "${OCF_RESKEY_file} is a block device"
+ exit $OCF_ERR_ARGS # Invalid Argument
+ fi
+
+ if [ -d "${OCF_RESKEY_file}" ]; then
+ ocf_log err "${OCF_RESKEY_file} is a directory"
+ exit $OCF_ERR_ARGS # Invalid Argument
+ fi
+
+ if [ -c "${OCF_RESKEY_file}" ]; then
+ ocf_log err "${OCF_RESKEY_file} is a character device"
+ exit $OCF_ERR_ARGS # Invalid Argument
+ fi
+
+ if [ -p "${OCF_RESKEY_file}" ]; then
+ ocf_log err "${OCF_RESKEY_file} is a named pipe"
+ exit $OCF_ERR_ARGS # Invalid Argument
+ fi
+
+ if [ -S "${OCF_RESKEY_file}" ]; then
+ ocf_log err "${OCF_RESKEY_file} is a socket"
+ exit $OCF_ERR_ARGS # Invalid Argument
+ fi
+
+ if ! [ -s "${OCF_RESKEY_file}" ]; then
+ ocf_log err "${OCF_RESKEY_file} is empty"
+ exit $OCF_ERR_GENERIC # ???
+ fi
+
+ if ! [ -x "${OCF_RESKEY_file}" ]; then
+ ocf_log err "${OCF_RESKEY_file} is not executable"
+ exit $OCF_ERR_PERM
+ fi
+
+ return 0
+}
+
case $1 in
meta-data)
meta_data
exit 0
;;
validate-all)
- exit 0 # XXX XXX XXX
+ validate_or_exit
+ exit 0
;;
*)
;;
esac
-[ -n "${OCF_RESKEY_file}" ] || exit $OCF_ERR_ARGS # Invalid Argument
-[ -f "${OCF_RESKEY_file}" ] || exit $OCF_ERR_INSTALLED # Program not installed
-[ -x "${OCF_RESKEY_file}" ] || exit $OCF_ERR_GENERIC # Generic error
+validate_or_exit
# Don't need to catch return codes; this one will work.
ocf_log info "Executing ${OCF_RESKEY_file} $1"
--
1.7.7.6
^ permalink raw reply related [flat|nested] 2+ messages in thread
* [Cluster-devel] [PATCH] Med: Improve script.sh's error reporting (RHEL6)
2012-11-26 15:23 [Cluster-devel] [PATCH] Med: Improve script.sh's error reporting (RHEL6) Lon Hohberger
@ 2012-11-29 20:28 ` Lon Hohberger
0 siblings, 0 replies; 2+ messages in thread
From: Lon Hohberger @ 2012-11-29 20:28 UTC (permalink / raw)
To: cluster-devel.redhat.com
On 11/26/2012 10:23 AM, Lon Hohberger wrote:
> The script agent used primarily by rgmanager had a very minimal amount
> of error reporting, such that it could be very confusing as to why a
> script resource had failed.
>
> This patch looks for a variety of errors from the script resource.
>
Replaced pull request here based on Jan's comments.
https://github.com/ClusterLabs/resource-agents/pull/183
-- Lon
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2012-11-29 20:28 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-11-26 15:23 [Cluster-devel] [PATCH] Med: Improve script.sh's error reporting (RHEL6) Lon Hohberger
2012-11-29 20:28 ` Lon Hohberger
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).