public inbox for cluster-cvs@sourceware.org
help / color / mirror / Atom feed
* cluster: STABLE3 - libfence/fence_node: use different exit code when unfencing undefined
@ 2009-02-26 18:57 David Teigland
  0 siblings, 0 replies; only message in thread
From: David Teigland @ 2009-02-26 18:57 UTC (permalink / raw)
  To: cluster-cvs-relay

Gitweb:        http://git.fedorahosted.org/git/cluster.git?p=cluster.git;a=commitdiff;h=537c6d1b24fc5767c45025dd866d6d77e2a7f920
Commit:        537c6d1b24fc5767c45025dd866d6d77e2a7f920
Parent:        6e4790ff21127e92714bc3f6911075858d620d3c
Author:        David Teigland <teigland@redhat.com>
AuthorDate:    Thu Feb 26 12:53:01 2009 -0600
Committer:     David Teigland <teigland@redhat.com>
CommitterDate: Thu Feb 26 12:53:01 2009 -0600

libfence/fence_node: use different exit code when unfencing undefined

Allow callers to more easily distinguish between unfencing failing
because it's not defined (common), and unfencing failing because
it was defined, tried and failed.

Signed-off-by: David Teigland <teigland@redhat.com>
---
 fence/fence_node/fence_node.c |   38 +++++++++++++++++++++++++++-----------
 fence/libfence/agent.c        |    5 ++++-
 2 files changed, 31 insertions(+), 12 deletions(-)

diff --git a/fence/fence_node/fence_node.c b/fence/fence_node/fence_node.c
index 1e3c293..c87ee07 100644
--- a/fence/fence_node/fence_node.c
+++ b/fence/fence_node/fence_node.c
@@ -210,18 +210,34 @@ int main(int argc, char *argv[])
 	logt_init("fence_node", LOG_MODE_OUTPUT_SYSLOG, SYSLOGFACILITY,
 		  SYSLOGLEVEL, 0, NULL);
 
-	if (error) {
-		fprintf(stderr, "%s %s failed\n", action, victim);
-		logt_print(LOG_ERR, "%s %s failed\n", action, victim);
-		rv = EXIT_FAILURE;
+	if (unfence) {
+		if (error == -2) {
+			fprintf(stderr, "unfence %s undefined\n", victim);
+			rv = 2;
+		} else if (error) {
+			fprintf(stderr, "unfence %s failed\n", victim);
+			logt_print(LOG_ERR, "unfence %s failed\n", victim);
+			rv = EXIT_FAILURE;
+		} else {
+			fprintf(stderr, "unfence %s success\n", victim);
+			logt_print(LOG_ERR, "unfence %s success\n", victim);
+			rv = EXIT_SUCCESS;
+		}
 	} else {
-		fprintf(stderr, "%s %s success\n", action, victim);
-		logt_print(LOG_ERR, "%s %s success\n", action, victim);
-		rv = EXIT_SUCCESS;
-
-		/* Tell fenced what we've done so that it can avoid fencing
-		   this node again if the fence_node() rebooted it. */
-		fenced_external(victim);
+		if (error) {
+			fprintf(stderr, "fence %s failed\n", victim);
+			logt_print(LOG_ERR, "fence %s failed\n", victim);
+			rv = EXIT_FAILURE;
+		} else {
+			fprintf(stderr, "fence %s success\n", victim);
+			logt_print(LOG_ERR, "fence %s success\n", victim);
+			rv = EXIT_SUCCESS;
+
+			/* Tell fenced what we've done so that it can avoid
+			   fencing this node again if the fence_node() rebooted
+			   it. */
+			fenced_external(victim);
+		}
 	}
 
 	logt_exit();
diff --git a/fence/libfence/agent.c b/fence/libfence/agent.c
index 148be3c..46cf9c4 100644
--- a/fence/libfence/agent.c
+++ b/fence/libfence/agent.c
@@ -557,6 +557,9 @@ int unfence_node(char *victim, struct fence_log *log, int log_size,
 	if (ccs_lookup_nodename(cd, victim, &victim_nodename) == 0)
 		victim = victim_nodename;
 
+	/* return -2 if unfencing fails because there's no unfencing
+	   defined for the node */
+
 	num_devices = count_devices_unfence(cd, victim);
 	if (!num_devices) {
 		if (lp && left) {
@@ -565,7 +568,7 @@ int unfence_node(char *victim, struct fence_log *log, int log_size,
 			left--;
 		}
 		count++;
-		error = -1;
+		error = -2;
 		goto out;
 	}
 


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2009-02-26 18:57 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-02-26 18:57 cluster: STABLE3 - libfence/fence_node: use different exit code when unfencing undefined David Teigland

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 read-only IMAP folder(s) and NNTP newsgroup(s).