From: Lon Hohberger <lhh@redhat.com>
To: cluster-devel.redhat.com
Subject: [Cluster-devel] [PATCH] Med: Improve script.sh's error reporting (RHEL6)
Date: Mon, 26 Nov 2012 10:23:12 -0500 [thread overview]
Message-ID: <1353943392-313-1-git-send-email-lhh@redhat.com> (raw)
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
next reply other threads:[~2012-11-26 15:23 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-11-26 15:23 Lon Hohberger [this message]
2012-11-29 20:28 ` [Cluster-devel] [PATCH] Med: Improve script.sh's error reporting (RHEL6) Lon Hohberger
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1353943392-313-1-git-send-email-lhh@redhat.com \
--to=lhh@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.