[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

[Cluster-devel] patch proposal for BZ#514662



I'm not sure this ever made it to the list.


----- Forwarded message from edamato redhat com -----

Date: Mon, 3 Aug 2009 16:49:12 +0100
From: edamato redhat com
To: dct redhat com
Cc: cluster-devel redhat com,
        "Pancrazio `Ezio' de Mauro" <pdemauro redhat com>
Subject: patch proposal for BZ#514662
Message-ID: <20090803154912 GR23767 civitate fab redhat com>


Hi Dave,

As we discussed on #cluster, sending you this patch for BZ#514662. It implements readconfig and dumpconfig for fence_tool and fenced.

Thank you for the many corrections!!


I tested the last patch, and have:

[root pe1950-1 fence]# ./fence_tool/fence_tool dumpconfig
post_fail_delay = 80
post_join_delay = 8
clean_start = 0
skip_undefined = 0
override_path = /var/run/cluster/fenced_override

[root pe1950-1 fence]# ccs_tool update /etc/cluster/cluster.conf
Config file updated from version 679 to 680

Update complete.

[root pe1950-1 fence]# ./fence_tool/fence_tool readconfig

[root pe1950-1 fence]# ./fence_tool/fence_tool dumpconfig
post_fail_delay = 101
post_join_delay = 12
clean_start = 0
skip_undefined = 0
override_path = /var/run/cluster/fenced_override

[root pe1950-1 fence]# ./fence_tool/fence_tool dumpconfig
post_fail_delay = 101
post_join_delay = 12
clean_start = 0
skip_undefined = 0
override_path = /var/run/cluster/fenced_override


caveats:

- fence_tool readconfig must be run on every node.
- fence_tool readconfig is not testing if the fence domain is performing recovery, and updates it nonetheless. This should not be a problem because delay is set from post_fail_delay internally during recovery and should not affect fenced while doing recovery, but good to document anyway.

Let me know if you would like to have any modifications.

cheers
Eduardo.



-- 
-----

Eduardo Damato				Red Hat UK Ltd
Principal Technical Support Engineer 	200 Fowler Avenue
Tel:   +44 1252 362700			Farnborough Business Park
email: edamato redhat com		Farnborough, Hampshire GU14 7JP


diff -up cman-2.0.98.DIFF/fence/fenced/main.c.DIFF cman-2.0.98.DIFF/fence/fenced/main.c
--- cman-2.0.98.DIFF/fence/fenced/main.c.DIFF	2009-07-31 21:21:36.000000000 +0100
+++ cman-2.0.98.DIFF/fence/fenced/main.c	2009-08-03 16:13:12.000000000 +0100
@@ -379,6 +379,72 @@ static int do_dump(int fd)
 	return 0;
 }
 
+static int do_readconfig(int fd)
+{
+        char path[256], *str = NULL;
+        int error, cd, i = 0;
+
+        while ((cd = ccs_connect()) < 0) {
+                sleep(1);
+                if (++i > 9 && !(i % 10))
+                        log_error("connect to ccs error %d, "
+                                  "check ccsd or cluster status", cd);
+        }
+
+        if (comline.post_join_delay_opt == FALSE) {
+                str = NULL;
+                memset(path, 0, 256);
+                sprintf(path, "/cluster/fence_daemon/@post_join_delay");
+
+                error = ccs_get(cd, path, &str);
+                if (!error)
+                        comline.post_join_delay = atoi(str);
+                else
+                        comline.post_join_delay = DEFAULT_POST_JOIN_DELAY;
+                if (str)
+                        free(str);
+        }
+
+        if (comline.post_fail_delay_opt == FALSE) {
+                str = NULL;
+                memset(path, 0, 256);
+                sprintf(path, "/cluster/fence_daemon/@post_fail_delay");
+
+                error = ccs_get(cd, path, &str);
+                if (!error)
+                        comline.post_fail_delay = atoi(str);
+                else
+                        comline.post_fail_delay = DEFAULT_POST_FAIL_DELAY;
+                if (str)
+                        free(str);
+        }
+
+	if (error) {
+                        log_error("reconfigure: error reading ccs connector"
+                                  " %d, check ccsd or cluster status", cd);
+			return -1;
+	}
+
+	return 0;
+}
+
+static int do_dumpconfig(int fd)
+{
+	char buf[DUMP_SIZE];
+
+	memset(buf, 0, sizeof(buf));
+	sprintf(buf, "post_fail_delay = %d\n" "post_join_delay = %d\n"
+			"clean_start = %d\n" "skip_undefined = %d\n"
+			"override_path = %s\n",
+			comline.post_fail_delay, comline.post_join_delay,
+			comline.clean_start, comline.skip_undefined,
+			comline.override_path);
+
+	do_write(fd, buf, sizeof(buf));
+
+	return 0;
+}
+
 static int client_process(int ci)
 {
 	char buf[MAXLINE], *argv[MAXARGS], *cmd, *name, out[MAXLINE];
@@ -408,6 +474,10 @@ static int client_process(int ci)
 		rv = do_join(name);
 	else if (!strcmp(cmd, "leave"))
 		rv = do_leave(name);
+	else if (!strcmp(cmd, "readconfig"))
+		rv = do_readconfig(name);
+	else if (!strcmp(cmd, "dumpconfig"))
+		rv = do_dumpconfig(client[ci].fd);
 	else if (!strcmp(cmd, "dump")) {
 		do_dump(client[ci].fd);
 		close(client[ci].fd);
diff -up cman-2.0.98.DIFF/fence/fence_tool/fence_tool.c.DIFF cman-2.0.98.DIFF/fence/fence_tool/fence_tool.c
--- cman-2.0.98.DIFF/fence/fence_tool/fence_tool.c.DIFF	2009-07-31 19:54:15.000000000 +0100
+++ cman-2.0.98.DIFF/fence/fence_tool/fence_tool.c	2009-08-03 16:18:26.000000000 +0100
@@ -47,6 +47,8 @@
 #define OP_LEAVE 			2
 #define OP_WAIT				3
 #define OP_DUMP				4
+#define OP_READCONFIG			5
+#define OP_DUMPCONFIG			6
 
 /* needs to match the same in cluster/group/daemon/gd_internal.h and
    cluster/group/gfs_controld/lock_dlm.h and cluster/fence/fenced/fd.h */
@@ -432,11 +434,62 @@ static int do_dump(void)
 	return 0;
 }
 
+static int do_readconfig(void)
+{
+	char buf[MAXLINE];
+	int fd, rv;
+
+	fd = fenced_connect();
+
+	memset(buf, 0, sizeof(buf));
+
+	sprintf(buf, "readconfig");
+
+	rv = do_write(fd, buf, sizeof(buf));
+	if (rv < 0)
+		die("can't communicate with fenced");
+
+	memset(buf, 0, sizeof(buf));
+	rv = do_read(fd, buf, sizeof(buf));
+	if (rv < 0)
+		printf("readconfig: %s\n", strerror(errno));
+
+	close(fd);
+	return 0;
+}
+
+static int do_dumpconfig(void)
+{
+	char inbuf[DUMP_SIZE];
+	char outbuf[MAXLINE];
+	int fd, rv;
+
+	fd = fenced_connect();
+
+	memset(inbuf, 0, sizeof(inbuf));
+	memset(outbuf, 0, sizeof(outbuf));
+
+	sprintf(outbuf, "dumpconfig");
+
+	rv = do_write(fd, outbuf, sizeof(outbuf));
+	if (rv < 0)
+		die("can't communicate with fenced");
+
+	rv = do_read(fd, inbuf, sizeof(inbuf));
+	if (rv < 0)
+		printf("dump config: %s\n", strerror(errno));
+
+	do_write(STDOUT_FILENO, inbuf, strlen(inbuf));
+
+	close(fd);
+	return 0;
+}
+
 static void print_usage(void)
 {
 	printf("Usage:\n");
 	printf("\n");
-	printf("%s <join|leave|dump> [options]\n", prog_name);
+	printf("%s <join|leave|dump|dumpconfig|readconfig> [options]\n", prog_name);
 	printf("\n");
 	printf("Actions:\n");
 	printf("  join             Join the default fence domain\n");
@@ -515,6 +568,10 @@ static void decode_arguments(int argc, c
 			operation = OP_LEAVE;
 		} else if (strcmp(argv[optind], "dump") == 0) {
 			operation = OP_DUMP;
+		} else if (strcmp(argv[optind], "dumpconfig") == 0) {
+			operation = OP_DUMPCONFIG;
+		} else if (strcmp(argv[optind], "readconfig") == 0) {
+			operation = OP_READCONFIG;
 		} else
 			die("unknown option %s\n", argv[optind]);
 		optind++;
@@ -537,6 +594,10 @@ int main(int argc, char *argv[])
 		return do_leave();
 	case OP_DUMP:
 		return do_dump();
+	case OP_READCONFIG:
+		return do_readconfig();
+	case OP_DUMPCONFIG:
+		return do_dumpconfig();
 	case OP_WAIT:
 		return -1;
 	}
diff -up cman-2.0.98.DIFF/fence/man/fence_tool.8.DIFF cman-2.0.98.DIFF/fence/man/fence_tool.8
--- cman-2.0.98.DIFF/fence/man/fence_tool.8.DIFF	2009-07-31 23:09:38.000000000 +0100
+++ cman-2.0.98.DIFF/fence/man/fence_tool.8	2009-08-03 16:12:35.000000000 +0100
@@ -13,12 +13,13 @@ fence_tool - A program to join and leave
 .SH SYNOPSIS
 .B
 fence_tool
-<\fBjoin | leave | dump\fP> 
+<\fBjoin | leave | dump | dumpconfig | readconfig\fP> 
 [\fIOPTION\fR]...
 
 .SH DESCRIPTION
 \fBfence_tool\fP is a program used to join or leave the default fence
-domain.  It communicates with the fenced daemon.  Before telling fenced
+domain, but also to dump and reread the configuration from CCS.
+It communicates with the fenced daemon.  Before telling fenced
 to join the domain, fence_tool waits for the cluster to have quorum,
 making it easier to cancel the command if the cluster is inquorate.
 


----- End forwarded message -----


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]